mongoose-timestamps.js
v0.0.0
Published
Updates "updated_at" field on each save
Downloads
2
Maintainers
Readme
Mongoose Timestamps
Middleware to update timestamps
Install
npm install mongoose-timestamps.js
Usage
var mongoose = require('mongoose');
var updateTimestamps = require('mongoose-timestamps.js');
var schema = mongoose.Schema({
created_at: {type: Date, default: new Date()},
updated_at: {type: Date}
});
schema.pre('save', updateTimestamps('updated_at'));
License
MIT