我的 MongoDB 文档中有一个与此类似的“复杂”对象:
{_id: "5zvYuC37aXSAjGNEg",
profile: {
name: "profile_name",
keys:[{
keyID: "12345",
code: "12345",
chars:[{
name: "char_name1",
char_id: "12345",
active: 0
}, {
name: "char_name2",
char_id: "67890",
active: 0
}]
}]
}
}
active
是否可以根据char_id
我传递给查询的值来更新值?MySQL 中的等价物可能类似于:
UPDATE sometable SET active = 1 WHERE char_id = 12345
我尝试运行此查询:
Meteor.users.update(Meteor.userId(), {char_id:char_id}, {$set:{active:1} });
但在此之后,我的对象丢失了除_id
and之外的所有值char_id
。