Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Date 具有当前时间戳的Meteor集合查询_Date_Collections_Find_Meteor - Fatal编程技术网

Date 具有当前时间戳的Meteor集合查询

Date 具有当前时间戳的Meteor集合查询,date,collections,find,meteor,Date,Collections,Find,Meteor,我需要安排具有“scheduledAt”属性和时间戳(当前和预计)的项目。不幸的是,参考日期只计算一次 如何解决这个问题 Items.find({scheduledAt : {$lt : new Date()}}).observe(...) 因为Meteor是一个单页应用程序,“new Date()”不会被调用,除非您通过执行以下操作使其成为被动的: 函数findItems(){ Session.get 查找({scheduledAt:{$lt:new Date()}})。观察(…) } 你可

我需要安排具有“scheduledAt”属性和时间戳(当前和预计)的项目。不幸的是,参考日期只计算一次

如何解决这个问题

Items.find({scheduledAt : {$lt : new Date()}}).observe(...)

因为Meteor是一个单页应用程序,“new Date()”不会被调用,除非您通过执行以下操作使其成为被动的:

函数findItems(){ Session.get 查找({scheduledAt:{$lt:new Date()}})。观察(…) }

你可以通过这样做来触发 Session.set('triggerEvent')

如果您只想定期执行此操作,请使用Meteor.setTimeout()

传递“new Date()”将传递Date对象的toString(),这可能不是您想要的。尝试传递“+new Date()”以将其转换为实际时间戳。