是否有可能在不使用字符串构造查询的情况下在 ArangoDB 中编写以下查询?
// get all records where all given constraints are not null
LET constraints = ["size", "color", "model"]
FOR x IN some_collection
FOR c IN constraints
FILTER x[c] != null
RETURN x
不幸的是,这个变体不起作用
更新#1:
我已经设法通过以下肮脏的技巧做到了这一点:
LET constraints = ["size", "color", "model"]
FOR xxx IN some_collection
LET not_null_constraints = (
FOR item IN constraints
FILTER xxx[item] != null
RETURN 1
)
FILTER length(not_null_constraints) == length(constraints)
RETURN xxx
如果有更好的方法,请告诉我