2014-02-21 31 views
0

如果我执行从我的NodeJS应用以下更新:相对于数据库的日期的NodeJS蒙戈日期查询

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

我相信它会使用的NodeJS应用程序的时钟,有没有使用数据库的时钟,而不是一个办法吗?

回答

0

虽然我通常不会建议根据您的服务器时间应该同步,你可以使用eval()

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

,基本上将JavaScript函数来执行服务器,并返回结果。

阅读文档和谨慎使用