Arangodb AQL UPDATE for an object's internal field

Given the following sample collection document:

{ "timestamp": 1413543986, "message": "message", "readed": { "8": null, "9": null, "22": null }, "type": "1014574149174" } 

How to update the value of a specific key in an object using the "readed" key? For example, the update value for the key is "8":

 ... "8": 10, ... 
+5
source share
1 answer

You can use MERGE or MERGE_RECURSIVE as follows:

 db._query("FOR u IN test FILTER u._key == @key UPDATE u WITH 'read': MERGE_RECURSIVE(u.read, { '8': 10 }) } IN test", { key: "11611344050" }) 

Merge Combine documents where later values โ€‹โ€‹will be overwritten earlier. See http://docs.arangodb.org/Aql/Functions.html for more details.

+5
source

Source: https://habr.com/ru/post/1204921/


All Articles