对象内部字段的 Arangodb AQL 更新 [英] Arangodb AQL UPDATE for internal field of object
本文介绍了对象内部字段的 Arangodb AQL 更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给定以下示例文档集合:
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" })
Merge 将合并文档,后面的值会覆盖前面的值.详情请参阅 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 更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文