从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



