ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[toc] ## pre 创建一个Schema时,我们能通过`new mongoose.Schema`的第二个参数——配置对象,来为我们的Schema添加配置 ``` const UserSchema = new mongoose.Schema(define, {timestamps: true}); ``` ## timestamps 自动添加时间戳 ``` const UserSchema = new mongoose.Schema(define, {timestamps: true}); ``` ## collection 如果你指定Schema的时候指定了`collection`的值,那么会使用这个值作为集合的名字 ,否则就是模型名转小写再转复数 -> User-user-users ``` const UserSchema = new mongoose.Schema(define, {collection:'user'}); ```