【问题标题】:Meteor: find objects that are created todayMeteor:查找今天创建的对象
【发布时间】:2015-01-28 16:13:32
【问题描述】:

我正在尝试查找从今天开始的所有推文 (Tweets = new Meteor.Collection('tweets'))。

var today = new Date();
today.setHours(0);
today.setMinutes(0);
today.setSeconds(0);

结果:2014 年 11 月 30 日星期日 00:00:00 GMT+0100 (CET) - 看起来不错。但我的搜索查询

Tweets.find({createdAt: {$gte: today.toISOString()}}, {sort: {createdAt: -1}})

仍然返回一个空数组[]。我尝试了几种方法,但我不明白。怎么办?

【问题讨论】:

    标签: mongodb date meteor find


    【解决方案1】:

    我自己解决了这个简单的问题。

    Tweets.find({createdAt: {$gte: today}}, {sort: {createdAt: -1}})
    

    进一步阅读:https://meteor.hackpad.com/Meteor-Cookbook-Using-Dates-and-Times-qSQCGFc06gH

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-21
      • 1970-01-01
      • 2015-11-26
      • 2011-12-20
      • 2015-06-02
      • 2011-09-21
      • 1970-01-01
      相关资源
      最近更新 更多