A mongoose plugin that adds and maintains createdAt and updatedAt dates
npm install mongoose-cu-timestamps
Mongoose CU Timestamp
=====================
Mongoose CU (create & update) Timestamps adds and maintains a createdAt and
updatedAt property to affected schemas. Both fields are Date types. They
are also indexed.
``javascript`
Contact.findOne({ name: 'Robert Hurst' }, function(err, contact) {
// contact is {
// _id : 568da29c1fd5055957c88f4c
// name : 'Robert Hurst',
// createdAt: Mon Jan 04 2016 16:39:23 GMT-0800 (PST)
// updatedAt: Wed Jan 06 2016 16:39:23 GMT-0800 (PST)
// };
});
This package also adds a touch() method. The touch method is short hand for
the following.
`javascript``
contact.touch();
// same as
contact.updatedAt = new Date();
contact.save();