[英]Restheart aggregations: send dynamic $match query using $var
Can i send JSON in avars to dynamically create $match filter query as shown below: 我可以在avars中发送JSON来动态创建$ match过滤器查询,如下所示:
{
"type": "pipeline",
"uri": "myaggr",
"stages": [{
"$match": {"$var":"n"}
}......}
I have to pass JSON in place of {"$var":"n"} 我必须通过JSON代替{“ $ var”:“ n”}
please tell me if we have this option in Restheart or not... 请告诉我是否在Restheart中有此选项...
Having defined `{"$var": "n"} in your aggregation, you can pass the variable via query parameter 在聚合中定义了`{“ $ var”:“ n”}之后,您可以通过查询参数传递变量
GET /db/coll/_aggrs/myaggr?n={"all":{"the":{"json":"you want"}}}
However, in order to avoid query injection, you cannot pass MongoDB operators via aggregation variables unless you explicitly allow it by setting the following option in the configuration file: 但是,为了避免查询注入,除非通过在配置文件中设置以下选项明确允许,否则无法通过聚合变量传递MongoDB运算符:
### Security
# Check if aggregation variables use operators. allowing operators in aggregation variables
# is risky. requester can inject operators modifying the query
aggregation-check-operators: true
You can find all documentation about passing variables to aggregation at https://restheart.org/learn/aggregations/#passing-variables-to-aggregation-operations 您可以在https://restheart.org/learn/aggregations/#passing-variables-to-aggregation-operations中找到有关将变量传递给聚合的所有文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.