I need some help updating property of embedded collection with JSON structure below -
translation
{
"_id" : ObjectId("533d4c73d86b8977fda970a9"),
"_class" : "com.xxx.xxx.translation.domain.Translation",
"locales" : [
{
"_id" : "en-US",
"description" : "English (United States)",
"isActive" : true
},
{
"_id" : "pt-BR",
"description" : "Portuguese (Brazil)",
"isActive" : true
},
{
"_id" : "nl-NL",
"description" : "Dutch (Netherlands)",
"isActive" : true
}
],
"screens" : [
{
"_id" : "caseCodes",
"dictionary" : [
{
"key" : "CS_CAT1",
"parameterizedValue" : "My investigations",
"locale" : "en-US"
},
{
"key" : "MY_INVESTIGATIONS",
"parameterizedValue" : "",
"locale" : "pt-BR"
},
}
]
}
данных В приведенном выше структуре: Я хочу обновить «parameterizedValue» usinng весны-данные Монго-дб API 1.3.4, для экрана с _id = «caseCodes» и ключ = "CS_CAT1".Как обновить встроенное Монго документа с помощью пружины Монго апи
Я попытался (здесь «значения» это имя коллекции для TranslationValue массива)
mongoOperations.updateFirst(Query.query(Criteria.where("screens._id")
.is("caseCodes")), new Update().push(
"screens.dictionary.$.values", translationValue),
Translation.class);
но сказал, «не может добавить массив в строку„словарь“....
Любой указатели или помочь здесь? Спасибо.
-Sanjeev
Спасибо, Нейл. Это - «$ set»: { "screens.0.dictionary.1.parameterizedValue": "новое значение" } –
это сработало для меня. –