i have a mongodb database connected to a node.js app via mongodb-native-drivers. I am inserting data into the database, and need to timestamp it, the code looks like the following:
var server = new Server('localhost', 27017, { auto_reconnect: true }); var db = new Db('test', server); exports.fetch = function(args, callback) { db.open(function(err, db) { db.collection(args['device'], function(err, collection) { var doc = { device: args['device'], data: args['data'], time: new db.bson_serializer.Timestamp() } collection.insert(doc, { safe: true }, function(err,result) { db.close(); callback(lastestError); }); }); }); } The insert goes well, except for the timestamp, which is always 0! I have removed all error checking for clarity and size. Any help would be appreciated! Thanks.
Dateand something likeDate.now()? Does it have to be a Timestamp?