我正在尝试从 MongoDB 集合中获取结果。这是一个例子:
{ "entryDate" : "2012-10-14T00:00:00.000Z", "amount" : 1, "cardId" : "50786621e3b983f1078d0bc9", "_id" : ObjectId("507a17354c6cbd6a4b000001"), "addedDate" : "Sat Oct 13 2012 21:36:53 GMT-0400 (EDT)" }
{ "entryDate" : "2012-10-10T00:00:00.000Z", "amount" : 21, "cardId" : "50786639e3b983f1078d205e", "_id" : ObjectId("507a17394c6cbd6a4b000002"), "addedDate" : "Sat Oct 13 2012 21:36:57 GMT-0400 (EDT)" }
{ "entryDate" : "2012-10-09T00:00:00.000Z", "amount" : 1, "cardId" : "50786639e3b983f1078d205e", "_id" : ObjectId("507a25e46af510804c000002"), "addedDate" : "Sat Oct 13 2012 22:39:32 GMT-0400 (EDT)" }
{ "entryDate" : "2012-10-08T00:00:00.000Z", "amount" : 12, "cardId" : "50786621e3b983f1078d0bc9", "_id" : ObjectId("507a2603b7a095824c000003"), "addedDate" : "Sat Oct 13 2012 22:40:03 GMT-0400 (EDT)" }
{ "entryDate" : "2012-10-08T00:00:00.000Z", "amount" : 1, "cardId" : "507865e1e3b983f1078ceb3f", "_id" : ObjectId("507a2667b7a095824c000004"), "addedDate" : "Sat Oct 13 2012 22:41:43 GMT-0400 (EDT)" }
{ "entryDate" : "2012-10-15T00:00:00.000Z", "amount" : 2, "cardId" : "50786621e3b983f1078d0bc9", "_id" : ObjectId("507a48c170b1a26f4f000001"), "addedDate" : "Sun Oct 14 2012 01:08:17 GMT-0400 (EDT)" }
这是我要执行的查询:(这是集合)
// (these are JS Date objects)
// start = Sun Oct 7 2012 13:22:02 GMT-0400 (EDT)
// end = Sat Oct 20 2012 13:22:02 GMT-0400 (EDT)
this.find({ cardId: cardId, entryDate: { $lt : start, $gt : end } }).toArray(function(err, entries) { console.log(err, entries) });
但不幸的是,它总是返回[]
并且没有错误。
有任何想法吗?我肯定做错了什么,但我一直在寻找很长时间,所以我请求你的帮助。
非常感谢,祝您有美好的一天!