本文介绍了Meteor.userId 与 Meteor.userId()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一小段代码,如下所示,用于更新我用户个人资料中的名称:

I have a short piece of code, like so, to update the name in my user's profile:

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

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

When I'm working locally, I can use Meteor.userId or Meteor.userId() without issue. However, when I deploy to Modulus, I run into issues. If I don't have the operator on it, it will do the initial $set, but no more. If I user the operators, it behaves as I would expect.

这是为什么?我认为我不应该在没有操作员的情况下使用它,但是有什么理由让它起作用吗?

Why is this? I assume that I shouldn't have been using this without the operator to begin with, but is there a reason why it worked at all?

推荐答案

查看文档

  • 函数 Meteor.userId() 可用于任何地方但发布函数"

  • The function Meteor.userId() is available "Anywhere but publish functions"

变量 this.userId 在任何地方"都可用(服务器端发布功能也明确调用了该变量).

The variable this.userId is available "Anywhere" (which explicitly is also called out for the Server side Publish function).

这篇关于Meteor.userId 与 Meteor.userId()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 09:54