【问题标题】:Push/Pull Value(s) to Array in ArangoJS在 ArangoJS 中将值推送/拉取到数组
【发布时间】:2018-05-16 18:21:16
【问题描述】:

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

如果我有文件...

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

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

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

谢谢!

【问题讨论】:

    标签: arangodb arangojs


    【解决方案1】:

    您可以通过 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

    【讨论】:

      猜你喜欢
      • 2020-10-23
      • 2020-02-21
      • 2017-03-21
      • 2021-09-21
      • 1970-01-01
      • 2016-07-07
      • 1970-01-01
      • 2020-11-17
      • 1970-01-01
      相关资源
      最近更新 更多