[英]how to append a value to map[string][]string in arango using aql
如何使用aql查詢將值附加到字符串數組
{
"annotation_id": "1234",
"text": {
"june 2018": [
"gain of revenue for this month"
]
},
"user_id": ""
}
這是我的arango文件:
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查詢中完成
要添加到June2018數組中,可以使用push函數:
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": ""
}
}
]
您可以在其中看到預期的更改。
請注意,我將列從“ june 2018”更改為“ june2018”,這使我可以刪除所有引號,並使查詢更易於讀取(和寫入)。 通常,我不喜歡在列名中放置空格或其他特殊字符,因為它們實際上並沒有真正的目的,只是迫使我在所有地方都使用引號引起來。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.