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?
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 ?
Use an update
with $set
to modify specific fields of an existing document.
In the shell:
db.mycoll.update({"_id": ObjectId("54c955492b7c8eb21818bd09")}, {$set: {cuisine: "Fast"}})
In C# with an untyped collection:
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.