【发布时间】:2014-08-25 12:29:49
【问题描述】:
我正在从事 Meteor 项目,但由于某种原因,此个人资料模板无法正常工作。
我正在使用以下代码,以及用于用户管理的 accounts-password 和 accounts-entry 包:
this.route('profile', {
path: '/profile/:username',
data: function() {
var userDoc = Meteor.users.findOne({"username": this.params.username});
var bookCursor = Books.find({owner: userDoc._id});
return {
theUser: userDoc,
theBooks: bookCursor
};
}
});
当我尝试访问我的测试帐户(分别为“misutowolf”和“test2”)的配置文件 URL 时,Chrome 的开发控制台中出现以下错误:Exception from Deps recompute function: TypeError: Cannot read property '_id' of undefined,指向使用 userDoc ._id 在对Books.find() 的调用中。
这毫无意义,因为我能够使用meteor mongo 和两个用户名(db.users.find({username: "misutowolf"}) 和db.users.find({username: "test2"}) 形式)找到具有相关名称的用户文档。
我很困惑,根本不知道是什么导致了这个问题。
【问题讨论】:
标签: mongodb meteor iron-router