drudge / mongoose-timestamp

Adds createdAt and updatedAt date attributes that get auto-assigned to the most recent create/update timestamp
Other
308 stars 64 forks source link

Global configuration/setup instead of by each model #33

Closed lesterzone closed 8 years ago

lesterzone commented 8 years ago

First: Thanks!

Second: I tried to research about the ability to enabled timestamps 'globally'. Is there a way to enable timestamps to the mongoose object?

like with promises:

let mongoose = require('mongoose');

mongoose.Promise = global.Promise;
kangsu-dev commented 8 years ago

You can use mongoose.plugin()

http://mongoosejs.com/docs/api.html#index_Mongoose-plugin

lesterzone commented 8 years ago

Thanks @kangsu-dev

let mongoose = require('mongoose');
let timestamps = require('mongoose-timestamp');
mongoose.plugin(timestamps);