
从Mongoose 4.0开始,您现在可以在Schema上设置一个timestamps选项,以让Mongoose为您处理:
var thingSchema = new Schema({..}, { timestamps: true });您可以像这样更改使用的字段的名称:
var thingSchema = new Schema({..}, { timestamps: { createdAt: 'created_at' } });http://mongoosejs.com/docs/guide.html#timestamps
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)