我收到错误消息Uncaught Error: When the modifier option is true, validation object must have at least one operator
我查看了number similar的questions,但无法解读我的查询有什么问题:
Meteor.users.update({
_id: Meteor.user()._id
}, {
$set: {
"emails.letter": true
}
})
我的MongoDB结构如下:
{
"_id": "ujkwQp4rYTKQeLq3F",
"emails": [{
"address": "admin@admin.com",
"letter": false
}]
}
答案 0 :(得分:1)
您需要指定要更新的数组中的哪个元素。试试这个:
Meteor.users.update({
_id : 123456,
"emails.address":"admin@admin.com"
}, {
$set: {
"emails.$.letter": true
}
});