Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arangodb 如何使用aql将值附加到arango中的map[string][]字符串_Arangodb - Fatal编程技术网

Arangodb 如何使用aql将值附加到arango中的map[string][]字符串

Arangodb 如何使用aql将值附加到arango中的map[string][]字符串,arangodb,Arangodb,如何使用aql查询将值附加到字符串数组 { "annotation_id": "1234", "text": { "june 2018": [ "gain of revenue for this month" ] }, "user_id": "" } 这是我的阿兰戈文件: for doc in annotation_info filter doc.annotation_id == '1234' update doc with {"text": {

如何使用aql查询将值附加到字符串数组

{
  "annotation_id": "1234",
  "text": {
    "june 2018": [
      "gain of revenue for this month"
    ]
  },
  "user_id": ""
}
这是我的阿兰戈文件:

for doc in annotation_info 
filter doc.annotation_id == '1234' 
update doc with {"text": {"june 2018":["test"]}} in annotation_info
我尝试了上面的查询,但它覆盖了现有的值,但我需要

{   "annotation_id": "1234",   "text": {
    "june 2018": [
      "gain of revenue for this month",
      "test"
    ]   },   "user_id": "" }
以下是我对arango文件的例外输出

{
  "annotation_id": "1234",
  "text": {
    "june 2018": [
      "gain of revenue for this month",
      "test"
    ]
  },
  "user_id": ""
}
这是我的例外输出,我只需要将值测试附加到2018年6月的键上,使用现有值。有人能帮我吗
这应该在aql查询中完成。要添加到2018年6月的阵列中,您可以使用推送功能:

{
  "annotation_id": "1234",
  "text": {
    "june 2018": [
      "gain of revenue for this month"
    ]
  },
  "user_id": ""
}
for doc in annotation_info 
filter doc.annotation_id == '1234' 
update doc with {text: {june2018 :push(doc.text.june2018, 'test')}} in annotation_info
RETURN { before: OLD, after: NEW } 
这将返回:

[
  {
    "before": {
      "_key": "45740",
      "_id": "test5/45740",
      "_rev": "_Z-plp5S--_",
      "annotation_id": "1234",
      "text": {
        "june2018": [
          "gain of revenue for this month"
        ]
      },
      "user_id": ""
    },
    "after": {
      "_key": "45740",
      "_id": "test5/45740",
      "_rev": "_Z-pl0cu--_",
      "annotation_id": "1234",
      "text": {
        "june2018": [
          "gain of revenue for this month",
          "test"
        ]
      },
      "user_id": ""
    }
  }
]
您可以看到预期的变化已经发生


请注意,我将该列从“2018年6月”改为“2018年6月”,这允许我删除所有引号,并使查询的读(写)更清晰。一般来说,我不喜欢在列名中添加空格或其他特殊字符,因为它们除了强制我在各处添加引号之外没有任何实际用途。

要添加到2018年6月的数组中,您可以使用推送功能:

for doc in annotation_info 
filter doc.annotation_id == '1234' 
update doc with {text: {june2018 :push(doc.text.june2018, 'test')}} in annotation_info
RETURN { before: OLD, after: NEW } 
这将返回:

[
  {
    "before": {
      "_key": "45740",
      "_id": "test5/45740",
      "_rev": "_Z-plp5S--_",
      "annotation_id": "1234",
      "text": {
        "june2018": [
          "gain of revenue for this month"
        ]
      },
      "user_id": ""
    },
    "after": {
      "_key": "45740",
      "_id": "test5/45740",
      "_rev": "_Z-pl0cu--_",
      "annotation_id": "1234",
      "text": {
        "june2018": [
          "gain of revenue for this month",
          "test"
        ]
      },
      "user_id": ""
    }
  }
]
您可以看到预期的变化已经发生


请注意,我将该列从“2018年6月”改为“2018年6月”,这允许我删除所有引号,并使查询的读(写)更清晰。一般来说,我不喜欢在列名中加空格或其他特殊字符,因为它们除了强迫我在所有地方加引号之外没有任何实际用途。

@stackoverflow我们看不到您期望的结果output@stackoverflow我们看不到你们的预期产量