Arangodb AQL UPDATE for internal field of object

三世轮回 提交于 2020-01-03 12:32:20

问题


Given the following example document of collection:

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

How do I update the value of specific key in object with key "readed"? For example update value for key "8":

...
   "8": 10,
...

回答1:


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 will merge documents, where later values will overwrite earlier ones. See http://docs.arangodb.org/Aql/Functions.html for details.



来源:https://stackoverflow.com/questions/26424894/arangodb-aql-update-for-internal-field-of-object

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!