【问题标题】:How to replace a status in array? [duplicate]如何替换数组中的状态? [复制]
【发布时间】:2018-03-17 20:23:20
【问题描述】:

我尝试使用数据查询修改文档。

这适用于正常结构。但是当查询是数组形式时。这似乎不会替换或修改状态。我怎样才能做到这一点?

这是我的数组

 `{
  "slave_state_datasets": [
    {
    "no": 0,
    "name": "abce",
    "status": true,
    "interrupt_time": 0.2,
    "timestamp": 1,
    "dataset_input": [
      {
      "data": 8,
      "ui16_u_u2": 1,
      "ui16_u_dip_min": 1,
      "ui16_u_swell_max": 1,
       }
    ]
  }
 ]
 }`

【问题讨论】:

    标签: arangodb aql


    【解决方案1】:

    在 3.3.3 上对此进行了测试,基于 this answer by RienNeVaPlu͢s

    for t in test
    filter t._key == '516226'
    let alteritem = (for s in t.slave_state_datasets
                let updateStatus = MERGE(s, {status: false})
            return updateStatus)
    update t with {slave_state_datasets:alteritem} IN test
    

    您将内部值分配给alteritem,将status 更新为MERGE,然后更新父文档。有关过滤数组的更多详细信息,请参阅链接答案。

    【讨论】:

      猜你喜欢
      • 2020-05-17
      • 1970-01-01
      • 2021-11-23
      • 2019-08-05
      • 2020-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-14
      相关资源
      最近更新 更多