[英]how can i can i do update single or multiple document in multiple collection with single aql query
我在数据库中有两个名为“collection1”和“collection2”的 collections 我为两个集合中的搜索文档创建了一个名为“myview”的视图
我在 collections 中都有以下文档->
{
"name": "Mac",
"age": 23,
"contry":"India",
"abc":true
}
如果 {"abc": false} 在 collection2 -> 中,此 aql 查询工作正常
FOR doc IN myview search doc.abc == true update doc with {"alive":true} in collection1 LET updated = OLD RETURN updated
但在我的情况下,这个条件在两个集合中都是 (abc == true) true 所以我如何使用单个 aql 查询更新多个集合中的单个或多个文档
不确定你想要什么,但这个查询能解决你的问题吗?
FOR doc IN myview
SEARCH doc.abc == true
UPDATE doc WITH {"alive":true} IN collection1 OPTIONS { ignoreErrors: true }
UPDATE doc with {"alive":true} IN collection2 OPTIONS { ignoreErrors: true }
LET updated = OLD
RETURN updated
OPTIONS { ignoreErrors: true }
即使文档不在集合中,也会使查询通过。
如果我们可以像这样对collections进行一些更改,例如对两个 collections 进行一些更改,例如使用更新操作
对于集合 1 ->
FOR doc IN myview
SEARCH doc.abc == true
UPDATE doc WITH {"alive":true} IN collection1 OPTIONS { ignoreErrors: true }
LET updated = OLD
RETURN updated
对于集合 2 ->
FOR doc IN myview
SEARCH doc.abc == true
UPDATE doc WITH {"alive":true} IN collection2 OPTIONS { ignoreErrors: true }
LET updated = OLD
RETURN updated
如何在单个 aql 查询中查询两个集合
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.