Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor 在群聊中添加参与者_Meteor_Sweetalert - Fatal编程技术网

Meteor 在群聊中添加参与者

Meteor 在群聊中添加参与者,meteor,sweetalert,Meteor,Sweetalert,我正在尝试在群聊中添加参与者,但没有收到任何错误,但没有发生任何事情。以下是我的代码: Meteor.methods({ addMember: function(groupId,email){ Groups.update({_id:groupId}, {$addToSet: {participants:{"emails":email}}} ); } }); 我的活动: Template.editGroup.events({ 'clic

我正在尝试在群聊中添加参与者,但没有收到任何错误,但没有发生任何事情。以下是我的代码:

Meteor.methods({
    addMember: function(groupId,email){
       Groups.update({_id:groupId},
       {$addToSet: {participants:{"emails":email}}}
     );
   }
});
我的活动:

  Template.editGroup.events({
  'click .add': function() {
    var id = this._id;
      swal({
              title: "An input!",
              text: "Add an email address:",
              type: "input",
              showCancelButton: true,
              closeOnConfirm: false,
              animation: "slide-from-top",
              inputPlaceholder: "Add email address"
          },
          function(email) {
              if (email === false) return false;
              if (email === "") {
               swal.showInputError("You need to add email  address!");
                  return false
              }
              Meteor.call("addMember",id,email)

          })
  }
})

id是meteor集合更新的第一个参数

见:

试试看

Meteor.methods({
    addMember: function(groupId,email){
       Groups.update(groupId,
       {$addToSet: {participants:{"emails":email}}}
     );
   }
});

您应该使用点符号来更新
参与者
中的
电子邮件
字段

只需将
{$addToSet:{参与者:{“电子邮件”:email}}}
替换为


{$addToSet:{“participants.emails”:email}

您能用您的组数据库模式更新吗