[英]How to save a portion of a large document mongoDB C# driver
Hi I have a document as follows 嗨,我有以下文件
{
"_id" : ObjectId("54c955492b7c8eb21818bd09"),
"address" : {
"street" : "2 Avenue",
"zipcode" : "10075",
"building" : "1480",
"coord" : [ -73.9557413, 40.7720266 ],
},
"borough" : "Manhattan",
"cuisine" : "Italian",
"grades" : [
{
"date" : ISODate("2014-10-01T00:00:00Z"),
"grade" : "A",
"score" : 11
},
{
"date" : ISODate("2014-01-16T00:00:00Z"),
"grade" : "B",
"score" : 17
}
],
"name" : "Vella",
"restaurant_id" : "41704620"
}
lets assume that this document is so large and I want to Save or Update the cuisine value without saving the whole document, will it possible from the .net ORM wrapper? 让我们假设此文档太大,并且我想保存或更新菜式值而不保存整个文档,是否可以使用.net ORM包装器?
Ex:- I only want to change the value "cuisine" without saving the whole document , please note that the real document is so big , will there be a performance issue ? 例如:-我只想更改“ cuisine”值而不保存整个文档,请注意实际文档是如此之大,是否会出现性能问题?
Use an update
with $set
to modify specific fields of an existing document. 使用$set
update
可修改现有文档的特定字段。
In the shell: 在外壳中:
db.mycoll.update({"_id": ObjectId("54c955492b7c8eb21818bd09")}, {$set: {cuisine: "Fast"}})
In C# with an untyped collection: 在带有无类型集合的C#中:
var filter = Builders<BsonDocument>.Filter.Eq("_id", new ObjectId("54c955492b7c8eb21818bd09"));
var update = Builders<BsonDocument>.Update.Set("cuisine", "Fast");
var result = await collection.UpdateOneAsync(filter, update);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.