mongoose-minute
Mongoose 4.0 plugin for setting created and updated timestamps.
npm install mongoose-minute
Usage
By default two additional properties are added to the schema createdAt
and updatedAt
. The timestamps are updated for each call to save
, update
and findOneAndUpdate
. The module uses hooks only available in Mongoose 4.0, and the MongoDB $setOnInsert
operator.
Pass the schema to the module.
var mongoose = ;var minute = ; var schema = counter: type: Number default: 0 ; ; var Model = db; // Set createdAt and updatedAt on model instancevar model = ;model; Model; Model;
Rename the properties using options.
;