您的位置:首页 > 数据库 > Mongodb

mongodb 更新数组

2014-02-18 09:49 302 查看
IMongoQuery query = Query.EQ("_id", new ObjectId(bsonAuthor.AuthorAuid));
BsonElement id = new BsonElement("id", "1");
BsonElement name = new BsonElement("name", "beijin");
BsonDocument bson = new BsonDocument(id, name);
IMongoUpdate update = Update.AddToSet("organization", bson);
bool b = GetCollection().Update(query, update).Ok;
return b;
更新完得到的结果
"organization" : [ { "id" : "1", "name" : "beijin" } ] }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  数组更新