Mongoose plugin that tracking the fields you specified and automatically record the change time of them into DB. It just like timestamps function of Mongoose itself.
Install
npm install mongoose-modified-at --save
Usage
Simply configure the schema on it initialization:
const modifiedAt = const articleSchema = title: String is_draft: Boolean is_recommended: Boolean // more... // before mongoose.model invokedarticleSchema const Article = mongoose
Create document:
await Article
Results from database:
"title": "Document Title" "is_draft": false "is_recommended": true "title_modifiedAt": "publishedAt": "recommendedAt": // more fields...
Documentation
See more details via the documentation.