0
votes

A Meteor client Template returns mongodb cursor. The collection has 3 documents which contain date field. I expected the find to return 3 documents, but it only gave one the date of which is Mon Aug 08 2016 00:00:00 GMT+1000 (AEST).

Why is that and how can I get the 3 documents? Thanks

"date" : ISODate("2016-08-08T14:00:00Z"),
"date" : ISODate("2016-08-08T14:00:00Z"),
"date" : ISODate("2016-08-07T14:00:00Z"),

console.log(start); //=> Sun Aug 07 2016 00:00:00 GMT+1000 (AEST)
console.log(end);   //=> Mon Aug 08 2016 00:00:00 GMT+1000 (AEST)

console.log(myCol.find({date: {$gte: start, $lte: end}}).fetch()); // expected 3 not just 1

the code below shows how the date was before inserting in the collection.

const date = cheerioObj(this).next().html().trim();
const dArr = date.split('/');
const dObj = new Date(parseInt(dArr[2]), parseInt(dArr[1]) - 1, parseInt(dArr[0]));
1

1 Answers

0
votes

EDIT: Sorry, it's late.

It may be to do with your .fetch() method. Try iterating the cursor instead:

var myArray = db.users.find({...}).toArray();

Then access each in a for loop.