将mongo查询转换为spring查询

时间:2018-12-19 14:31:19

标签: mongodb kotlin aggregation-framework spring-mongodb

MY mongo cli查询

  {$project:{"userId":{$setIntersection:["array1","array2"]}}}

我想将其转换为春季聚合投影。

我写以下查询

  var intersection=SetOperators.arrayAsSet("array1").intersects("pipe1","pipe2")

  var afterFacetStage=Aggregation.project().and(intersection).`as`("userId")

这等效于

{$project:{"userId":{$setIntersection:["array1","pipe1","pipe2"]}}}

没想到我不想包含arrayAsSet

Spring SetOperator Api

看到SetOperator类代码后,我找到了另一种方法

  var intersectOperation=SetOperators.SetOperatorFactory("array1").intersects("pipe1","pipe2")
    var afterFacetStage1=Aggregation.project().and(intersectOperation).`as`("userId")

仍会生成此意外查询

 {$project:{"userId":{$setIntersection:["array1","pipe1","pipe2"]}}}

0 个答案:

没有答案
相关问题