Angela
Angela

Reputation: 1074

Can't access MongoDB from Meteor

I'm using MeteorJS and I find that whenever I'm trying to access the properties of a MongoDB record, I get the following dump in the console
Exception from Deps recompute: TypeError: Cannot call method 'firstNode' of undefined at Object.Spark.renderToRange (http://localhost:2000/packages/spark/spark.js? 14a6d0456c829f0ae6b6b21c3d85c12b51d07167:545:25) at null._func (http://localhost:2000/packages/spark/spark.js?14a6d0456c829f0ae6b6b21c3d85c12b51d07167:866:13) at _.extend._compute (http://localhost:2000/packages/deps/deps.js?00c1c175771f1d01cbad3013d682a68610670394:126:14) at _.extend._recompute (http://localhost:2000/packages/deps/deps.js?00c1c175771f1d01cbad3013d682a68610670394:139:16) at _.extend.flush (http://localhost:2000/packages/deps/deps.js?00c1c175771f1d01cbad3013d682a68610670394:222:16) logging.js:41

Here is the code paste http://fpaste.org/7OC2/

Upvotes: 1

Views: 304

Answers (1)

Tarang
Tarang

Reputation: 75945

While meteor is finishing its subscriptions up and fetching data from the server, for a very short amount of time, the collections are empty.

So this query:

var result = QoD.findOne({week: Session.get('currentWeek')});

Wont have any results yet. You just need to handle this case in case there aren't any results:

if(result) Session.set('allResponses', result.responses); 

Upvotes: 1

Related Questions