1.0.0 • Published 8 years ago

mongoose-plugin-createdat v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

Mongoose plugin createdat NPM version

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 property
  • name: 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