0
我目前擁有「計劃」集合,它是在創建表單提交時創建的。它插入如下:Meteor Mongo將數據添加到現有集合
Plans.insert({
location,
address,
date,
time,
notes,
createdAt: new Date(), // current time
owner: Meteor.userId(),
username: Meteor.user().username,
attendees: [
{
attender: [{
user: String,
attending: Boolean,
}],
},
],
});
然後,在複選框的點擊,我希望有一個新的attender
對象添加到attendees
陣列。到目前爲止,我已經嘗試過:
'click .notattending'() {
Plans.insert(
{_id: this._id,
attendees: [{
attender: [
{
user: Meteor.user().username,
attending: false,
}
],
}
]
},
);
},
但是它並沒有添加到Mongo集合中。這是做這件事的正確方法嗎?
您應該更新文檔而不是插入 – collision