mongoose-cu-timestamps
v1.0.0
Published
A mongoose plugin that adds and maintains createdAt and updatedAt dates
Downloads
22
Maintainers
Readme
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.
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.
contact.touch();
// same as
contact.updatedAt = new Date();
contact.save();