0

If I perform the following update from my NodeJS app:

db.collection('test').update({name: 'some_name'}, {$set: {update_time: new Date()}}, {w:1}, function(err) {
  console.log('successfully updated');
});

I believe it will use the NodeJS app's clock, is there a way to use the database's clock instead?

Will I AM
  • 220
  • 1
  • 9

1 Answers1

0

Though I generally wouldn't recommend based on that your server times should be synchronized, you could use eval()

db.eval("function(){ return new Date() }", function(err, result) {
  console.log( result );
});

That basically sends the JavaScript function to the server to execute and returns the result.

Read the docs and use with caution.

Neil Lunn
  • 148,042
  • 36
  • 346
  • 317