Meteor.userId vs Meteor.userId()

Iti*_*ati 1 userid meteor

我有一小段代码,就像这样,在我的用户配置文件中更新名称:

Meteor.users.update({_id: Meteor.userId()}, {$set:{"profile.name": name}});

当我在本地工作时,我可以使用Meteor.userIdMeteor.userId()不使用问题.但是,当我部署到Modulus时,我遇到了问题.如果我没有操作符,它将执行初始$ set,但不会更多.如果我使用运算符,它的行为就像我期望的那样.

为什么是这样?我假设我不应该在没有操作员的情况下使用它,但它有什么原因可以使用吗?

Sor*_*ren 6

看看文档

  • 该功能Meteor.userId()可用"任何地方但发布功能"

  • 该变量this.userId可用于"Anywhere"(显式上也称为"服务器端发布"功能).