I am trying to update the attribute on json document in an embedded array using an ADLL.
User:
{name: "test", address: [["address", "address" ":" 1234 supervis ", type:" home " }, {"Addressline": "5678 Superva", type: "work"}]}
AulL attempts so far for the user
Update with the UET Editor with the URL. & Lt; What is here to update the address in YouTube? & Gt;}
To help you Thank you.
Regards, Anjan
To do this we need to work with the temporary variables. We will collect the mosaic there and change it.
First creates an archive with a sample:
< Code> database = db._create ('complexCollection') We choose a simple Boolean filter condition so that the query is better understood. ("AttributeToAlter": "oldValue", "filterByMe": true}, {"attributeToAlter" {"AttributeToAlter": "unchangedValue", "filterByMe": false}]}
is the query that is the sublist < To / em> alteredList To update it later:
Changed list for document in complex collection = (in element for document. SUBILITEIITIM = (! Element.filterByMe? Element: merge (element, {attributeToAlter: shiny new value "}") Returns new item) Update with document in {subList: changedList} Complex Collection Although this query is now functional:
db.complexCollection.toArray () [{"_id": "complexCollection / 392671569467", "_key": "392671569467", "_rev" True, "attributeToAlter": "393 9 9430203", "TopllyAttribute": "A", "Sublist": [{"FilterBeam": True, "SpecialtyOlator": "Brilliant New Value"}, {"FilterBeam" : "Shiny new value"}, {"filt ErByMe ": incorrect," attributeToAlter ":" unchangedValue "}]}]
This query may be a performance barrier soon, because it modified all in the archive The document whether the values change or not so we only want to update documents if we actually change their value so that we can check that The sublist will change,
complex for the document for the second for Neo What makes complexCollection LET willUpdateDocument = (Document.subList FILTER element.filterByMe LIMIT 1 for returns 1) Filter Lens (WillUpdateDocument) & gt; 0 changed list in written form = (for element in document). New element = (Element.filterByMe element: merge (element, {attributeToAlter: "shiny new value"})) Returns newITom {complexity compiled document} with {subList: changedList}
< / Div>
No comments:
Post a Comment