1.0.0 • Published 8 years ago

mongoose-plugin-updatedat v1.0.0

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

Mongoose plugin updatedat NPM version

Simple mongoose plugin to add a updated_at property to your schema, that automatically update with timestamp on change.

Install

npm install --save mongoose-plugin-updatedat

Usage

const Schema = require('mongoose').Schema;
const mongoosePluginUpdatedAt = require('mongoose-plugin-updatedat');

let MySchema = new Schema({ ... });
MySchema.plugin(mongoosePluginUpdatedAt);

Options

Available options:

  • index: if you want to index the property
  • name: the name of the field - default is updated_at

Example

const Schema = require('mongoose').Schema;
const mongoosePluginUpdatedAt = require('mongoose-plugin-updatedat');

let MySchema = new Schema({ ... });
MySchema.plugin(mongoosePluginUpdatedAt, {
  index: true,
  name: 'updated_at_custome_name',
});

License

MIT