mongoose plugin auto create timestamp and update timestamp.
npm install @bluewaitor/mongoose-plugin-timestamp --save
const mongoose = require('mongoose');
const timestampPlugin = require('@bluewaitor/mongoose-plugin-timestamp');
mongoose.plugin(timestampPlugin, {index: true});
const someSchema = mongoose.Schema({});
someSchema.plugin(timestampPlugin, {index: true});
this plugin will create two properties created
and updated
in models. custom properties not support yet.