【发布时间】:2018-05-19 19:47:23
【问题描述】:
每当用户登录他的帐户时,我都会收到异常,并且在刷新页面之前我看不到集合数据...... **[但如果我像这样使用它,我不会收到任何异常
Books.find({“customer_name”:this.userId);
而不是
Books.find({“customer_name”:Meteor.user().emails[0].address);
我不需要这一步,因为在我的应用中,用户集合的查找应该基于他们的电子邮件 ID,而不是用户 ID...]** 我的代码如下所示: 有人,请帮帮我:frowning_face:
服务器 - main.js:
var My_collection;
Meteor.publish(‘books’, function() {
My_collection =
Books.find({“customer_name”:Meteor.user().emails[0].address);
return My_collection;
客户端-main.js:
Template.viewBooks.helpers({
books() {
return Books.find({}, { sort: { books_order: -1 } }).fetch();
},
});
客户端 - main.html
{{#each books}}
{{books_id}}
{{/each}}
错误:
应用程序运行在:http://localhost:3000/I20171205-16:06:49.773(5.5)? 来自子事务 id wQ9DpjjABEiPzMZ9P TypeError 的异常:不能 读取 null I20171205-16:06:49.872(5.5) 的属性“电子邮件”?在 Subscription._handler (server/main.js:16:75) I20171205-16:06:49.873(5.5)?在 MaybeAuditArgumentChecks (包/ddp-server/livedata_server.js:1768:12) I20171205-16:06:49.873(5.5)?在 DDP.CurrentPublicationInvocation.withValue (包/ddp-server/livedata_server.js:1043:15) I20171205-16:06:49.873(5.5)?在 Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1134:15) I20171205-16:06:49.873(5.5)?在 Subscription.runHandler (包/ddp-server/livedata_server.js:1041:51) I20171205-16:06:49.873(5.5)?在 包/ddp-server/livedata_server.js:826:41 I20171205-16:06:49.874(5.5)?在函数..each..forEach (packages/underscore.js:147:22) I20171205-16:06:49.874(5.5)?在 包/ddp-server/livedata_server.js:822:9 I20171205-16:06:49.874(5.5)?在 Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1134:15) I20171205-16:06:49.874(5.5)?在 Session._setUserId (packages/ddp-server/livedata_server.js:816:34)
【问题讨论】:
标签: meteor