I have added new field in user collection but when I access it in the client side Meteor.user().cart ( cart is my new field). Its undefined. How can expose new field (cart) so that it can be access in the client?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The easiest way is to add a null
publisher which will automatically send the data without the need for a subscription. Be sure to limit the fields to only the ones you need.
Meteor.publish(null, function() {
return Meteor.users.find(this.userId, {fields: {cart: 1}});
});