Mongo ReactiveStream-Java IndexOfArray

问题描述

我的mongo文件如下。

{
  "owner":1,"products": [
     123,234,456,789 
   ]
},{
  "owner":2,"products": [
     312,423,654,878 
   ]
}

我的要求是检查给定所有者的数组中是否存在给定元素,并返回数组的索引。

db.inventory.aggregate(
   [
     {
       $project:
          {
            index: { $indexOfArray: [ "$products",123 ] },},$match:
          {
            "owner": 1
          }
      }
   ]
)

不确定Mongo Java的操作方法

使用mongo-driver-core:4.03和mongo-driver-reactivestreams:4.0.3

Mono.from(collection.aggregate(Arrays.asList(project(???),match(eq(ownerId)))));

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)