【发布时间】:2014-07-19 22:28:25
【问题描述】:
我正在尝试将自定义余额字段添加到meteor.user 集合,但我在从客户端访问它时遇到问题。
如果我使用自动发布和不安全创建一个新项目,则事件将不起作用。假设我要发布用户集合的 createdAt 字段:
# server
if Meteor.isServer
Meteor.publish "userData", ->
console.log @userId
if @userId
Meteor.users.find
_id: @userId
,
fields:
createdAt: 1
else
@ready()
return
# client
if Meteor.isClient
Meteor.subscribe "userData"
/project/collections/user.coffee
无论如何,当我在浏览器的控制台中键入 Meteor.user() 时,我仍然无法读取 createdAt 字段。我做错了什么?
【问题讨论】:
标签: coffeescript meteor