mongoose-cu-timestamps

1.0.0 • Public • Published

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();

Package Sidebar

Install

npm i mongoose-cu-timestamps

Weekly Downloads

7

Version

1.0.0

License

MIT

Last publish

Collaborators

  • robertwhurst