Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor collection find() does not retrieve any data

I'm working through a meteor tutorial : https://www.meteor.com/tutorials/blaze/collections

I have a collection defined,

Tasks = new Mongo.Collection("tasks");

I've added two items to it, one directly from meteor mongo command line, and another one using:

Tasks.insert({ text: "Testing JS", createdAt: new Date() });

Here are the results from running db.tasks.find() on the backend:

{ "_id" : ObjectId("559e9569abbb64fe1d5fd89a"), "text" : "Hello world!", "createdAt" : ISODate("2015-07-09T15:38:17.742Z") }
{ "_id" : "obRN8Rcssa9yJqXzA", "text" : "Testing JS", "createdAt" : ISODate("2015-07-09T17:00:13.285Z") }

But when I run Tasks.find({}); on the front end, I get empty result. It just gives me a long JSON but no data from the database.

like image 606
Tim Zhukov-Khovanskiy Avatar asked Jul 09 '15 17:07

Tim Zhukov-Khovanskiy


1 Answers

In meteor, you can view the documents returned by a cursor by calling fetch on it. For example:

console.log(Tasks.find().fetch());
like image 114
David Weldon Avatar answered Oct 10 '22 02:10

David Weldon