Here's my Application document
{
"_id": "binary_stuff",
"Name": "MyApplication",
"Settings": [
{
"_id": "binary_stuff",
"Key": "ImportDirectory",
"Value": "C:\data",
"Overrides": [{
"_id": "binary_stuff",
"NewValue": "C:\anotherData"
}]
},
}
I know how to add a Settings subdocument but how can I add a new Override "subsubdocument".
I tried:
var query = Query.And(Query.E开发者_运维知识库Q("_id", applicationId), Query.EQ("Settings._id", settingId));
var update = Update.AddToSetWrapped("Settings.Overrides", overrideViewModel.ToBsonDocument());
Run(database => database.Applications().Update(query, update, UpdateFlags.Upsert, SafeMode.True));
It does nothing...
Any help would be appreciated.
Thanks guys !!
I found the answer, I had to use the operational $
var query = Query.And(Query.EQ("_id", applicationId), Query.EQ("Settings._id", settingId));
var update = Update.AddToSetWrapped("Settings.Overrides", overrideViewModel.ToBsonDocument());
Run(database => database.Applications().Update(query, update, UpdateFlags.Upsert, SafeMode.True));
精彩评论