Pregunta

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?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top