Another mongoose created-at module. Gives you some options to change the path and indexing object.
'use strict';
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var MySchema = new Schema({
name: String
});
MySchema.plugin(require('mongoose-created-at'));
To pass in options:
MySchema.plugin(require('mongoose-created-at'), {
createdAtPath: 'createdAt',
index: false
});
createdAtPath
(String) - The path to add the createdAt property. Default:'createdAt'
index
(Mixed) - The indexing options given to this field. See http://mongoosejs.com/docs/api.html#schematype_SchemaType-index. Default:false