2017-03-06 53 views
0

我想在羣聊中添加的參與者,但我沒有得到任何錯誤,但沒有什麼是這裏發生的一切是我的代碼:在羣聊中添加參與者

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) 

      }) 
    } 
}) 
+0

取代{$addToSet: {participants:{"emails":email}}}你可以用組數據庫架構更新,請 – rubie

回答