最新版本的猫鼬如何根据日期字段进行查询? [英] How to query based on a Date field in the latest version of Mongoose?

查看:43
本文介绍了最新版本的猫鼬如何根据日期字段进行查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个模型:

var model = {
      created: { type: Date, default: Date.now }
    , data: { }
}

...但我似乎无法根据我正在使用的指南根据日期进行选择.这是我正在尝试的:

...but I cannot seem to select based on a date as per the guides I'm using. Here's what I'm trying:

Model.find({
    created: { $lte: new Date('2012-03-16T20:54:35.630Z') }
}).run(function(err, models) {
    // ...
});

我想知道猫鼬是不是又变了……还是我做错了?

I'm wondering if Mongoose has changed again... or if I'm just doing it wrong?

推荐答案

你所拥有的看起来不错.这是一个工作示例.

What you have looks ok. Here is a working example.

您是收到错误还是没有结果?

Are you getting error or just no results?

另一个获得帮助的好地方是官方论坛这里.

Another great place to get help is on the official forum here.

这篇关于最新版本的猫鼬如何根据日期字段进行查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆