coke
Version:
A full stack MVC framework that speeds up your web development.
31 lines (25 loc) • 539 B
JavaScript
var Schema = function ( Schema ){
/**
* Module dependencies.
* @private
*/
var ObjectId = Schema.ObjectId;
var Models = {
};
// auto update `updated_at` on save
Object.keys( Models ).forEach( function ( model ){
if( Models[ model ].tree.updated_at !== undefined ){
Models[ model ].pre( 'save', function ( next ){
this.updated_at = this.isNew?
this.created_at :
Date.now();
next();
});
}
});
return Models;
};
/**
* Exports module.
*/
module.exports = Schema;