angular meteor如何在client/myComponent.js中更新用户数据,而不是在google控制台中

angular meteor如何在client/myComponent.js中更新用户数据,而不是在google控制台中,meteor,terminal,console,angular-meteor,meteor-useraccounts,Meteor,Terminal,Console,Angular Meteor,Meteor Useraccounts,目标是将例如2欧元从user1转移到user2 model/myComponents.js Meteor.users.allow({ update: function (userId) { //check if an user is connected if(userId == null){ return false; }else{ return true; } }, remove: function () { r

目标是将例如2欧元从user1转移到user2

model/myComponents.js

Meteor.users.allow({
  update: function (userId) {   
    //check if an user is connected
    if(userId == null){
      return false;
    }else{
      return true;
    }
  },
  remove: function () {
    return false;
  }
});
...
this.chooseWinner = (subject,comment) => {
...
// this works
Meteor.users.update({_id: comment.user_id}, {$set:{credit : winCash}});
...
客户端/myComponents.js

Meteor.users.allow({
  update: function (userId) {   
    //check if an user is connected
    if(userId == null){
      return false;
    }else{
      return true;
    }
  },
  remove: function () {
    return false;
  }
});
...
this.chooseWinner = (subject,comment) => {
...
// this works
Meteor.users.update({_id: comment.user_id}, {$set:{credit : winCash}});
...
在谷歌chrome终端中,我可以这样做:

Meteor.userId();

I obtain something like : "HTjgBTBcBk4npQSBe"
Meteor.users.update({_id: "HTjgBTBcBk4npQSBe"}, {$set:{credit : 12.34}});

!!!! Then the credit of this user is modified !!!!!
进入谷歌chrome终端后,我可以这样做:

Meteor.userId();

I obtain something like : "HTjgBTBcBk4npQSBe"
Meteor.users.update({_id: "HTjgBTBcBk4npQSBe"}, {$set:{credit : 12.34}});

!!!! Then the credit of this user is modified !!!!!
如何在client/myComponent.js中更新,而不是在谷歌控制台中更新?

谢谢

谢谢@Leaf

我不再使用“允许”或“拒绝”

用流星法更安全

我用了这个文件:


希望,这可以帮助别人。

你能尝试使用Meteor.Call()和服务器端方法进行更新吗?@Leaf是的,这是很简单的正确方法。非常感谢。