我正在使用MeteorJS,我发现无论何时我试图访问MongoDB记录的属性,我都会在控制台中获得以下转储
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
以下是代码粘贴http://fpaste.org/7OC2/
答案 0 :(得分:1)
当meteor正在完成订阅并从服务器获取数据时,在很短的时间内,这些集合都是空的。
所以这个查询:
var result = QoD.findOne({week: Session.get('currentWeek')});
还没有任何结果。如果没有任何结果,您只需要处理这种情况:
if(result) Session.set('allResponses', result.responses);