在 Meteor 中,如何在给定年、月、日的集合中查找记录?

In Meteor, how do I find a record in a collection given the year, month, day?

所以我有一个帖子集合,其中 JavaScript 日期对象存储在 "submitted" 字段中。鉴于 year/month/day(例如 2015/02/03),我需要能够提取符合此描述的记录。

我试过类似的方法,但没有用。我对正确的语法一无所知:

Posts.find({$where : 'return this.submitted.getMonth() == 2 && this.submitted.getDay() == 3 && this.submitted.getYear() == 2015'})

此外,一开始就在集合中单独存储 3 个单独的变量对我来说更好吗?喜欢 submitted.yearsubmitted.monthsubmitted.day。听起来简单多了,但是需要加一大堆字段,看起来有点多余。

这是 question. The solution is to search within a date range. Tweak下面的查询:

Posts.find({submitted: {$gte: new Date('2015-02-23'), $lt: new Date('2015-02-04')}})