Push/Pull ArangoJS 中数组的值

Push/Pull Value(s) to Array in ArangoJS

我正在过渡到 ArangoDB,因为它作为图形数据库的强大功能,并且正在为简单的事情而苦苦挣扎。

如果我有文件...

{ _id:'1234', tags:['apple','orange'] }

如何更新它以从数组中推送或提取值?我希望语法是这样的,但在文档中没有找到任何内容...

collection.update({ _id:'1234' },{ tags:pull('mango') })
collection.update({ _id:'1234' },{ tags:push('avocado') })

谢谢!

您可以使用 AQL 实现此目的。例如

FOR c in collection UPDATE c WITH { tags : PUSH(c.tags, 'avocado')} IN collection

https://docs.arangodb.com/3.3/AQL/Operations/Update.html