mongoose-plugin-createdat
v1.0.0
Published
Mongoose plugin that add a created_at field to schema
Downloads
2
Readme
Mongoose plugin createdat
Simple mongoose plugin to add a created_at property to your schema, set on object save at the first time.
Install
npm install --save mongoose-plugin-createdat
Usage
const Schema = require('mongoose').Schema;
const mongoosePluginCreatedAt = require('mongoose-plugin-createat');
let MySchema = new Schema({ ... });
MySchema.plugin(mongoosePluginCreatedAt);
Options
Available options:
index
: if you want to index the propertyname
: the name of the field - default is created_at
Example
const Schema = require('mongoose').Schema;
const mongoosePluginCreatedAt = require('mongoose-plugin-createat');
let MySchema = new Schema({ ... });
MySchema.plugin(mongoosePluginCreatedAt, {
index: true,
name: 'created_at_custome_name',
});
License
MIT