0
我對mongodb非常陌生,我想知道何時添加嵌入式文檔,如果有方法我只能檢查person_Id而不是活動字段。我只關心爲person_id的不重複在Mongodb中,如何檢查嵌入文檔中的重複內容
collection.update({'_id':new BSON.ObjectID(business_id)}, {$addToSet: {members : {person_Id : person_id, active : true }}}, {safe:true}, function(err, result) {
if (err) {
console.log('Error updating person: ' + err);
} else {
console.log('' + result + ' document(s) updated');
callback(result);
}
});
http://stackoverflow.com/questions/4435637/mongodb-unique-key-in-embedded-document的可能重複 – aga 2013-02-11 06:26:08