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}
您能用您的组数据库模式更新吗