Hello!

I set the timestamp field in the scheme (as in the manual, for getting the time to create / edit the record)

var mongose = require('mongose'); mongose.connect('mongodb://localhost/test'); var Schema = mongose.Schema; var sh = new Schema({ guid: String, type:String, name: String}, {timestamp: true} ); var model = mongose.model('Item', sh); ... var data = {type:type, name:name}; model.update({guid: guid}, data, {upsert: true}); 

but it does not appear in find

 model .find({type:type}) .sort({'timestamp':'desc'}) .exec(function(err,items){ items.forEach(function(e){ console.log(e.timestamp); ... }) }) 

at the exit:

undefined

undefined

how to get it?

    1 answer 1

     var mongose = require('mongose'); mongose.connect('mongodb://localhost/test'); var Schema = mongose.Schema; var sh = new Schema({ guid: String, type:String, name: String}); sh.virtual('date') .get(function(){ return this._id.getTimestamp(); }); 

    date - and your timestamp will be