对象内部字段的Arangodb AQL UPDATE [英] Arangodb AQL UPDATE for internal field of object

查看:390
本文介绍了对象内部字段的Arangodb AQL UPDATE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出以下收集示例文件:

Given the following example document of collection:

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

如何使用已读取"键更新对象中特定键的值?例如,键"8"的更新值:

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

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

推荐答案

您可以按以下方式使用MERGE或MERGE_RECURSIVE:

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" })

合并将合并文档,其中较新的值将覆盖较早的文件.有关详细信息,请参见 http://docs.arangodb.org/Aql/Functions.html .

Merge will merge documents, where later values will overwrite earlier ones. See http://docs.arangodb.org/Aql/Functions.html for details.

这篇关于对象内部字段的Arangodb AQL UPDATE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆