[英]Scala MongoDB Driver does not find Objects
In my Scala Application, I am trying to find()
all Objects for a List of ObjectId
s. 在我的Scala应用程序中,我试图为ObjectId
列表find()
所有对象。
My DB Structure looks like that: 我的数据库结构如下所示:
case class Parent(_id: ObjectId, name: String)
case class Child(_id: ObjectId, name: String, parents: List[ObjectId])
Now, I have a list of ParentIds and want to find all Parents.find(in("_id", foundChild.parents))
. 现在,我有一个ParentIds列表,想要查找所有Parents.find(in("_id", foundChild.parents))
。
Unfortunately, parents
will be empty. 不幸的是, parents
会空着。 I have searched the Internet for a in("_id", List[ObjectId])
-Example, but couldn't find a single one. 我已经在Internet上搜索了in("_id", List[ObjectId])
示例,但是找不到一个。
Reading the documentation , it seems like it is not supported to check for lists, but only for TItem*
. 阅读文档 ,似乎不支持检查列表,而仅支持TItem*
。 Is it possible to achieve a "is in List" Check somehow? 是否有可能以某种方式实现“在列表中”检查?
以varargs的形式传入List
:
Parents.find(in("_id", foundChild.parents: _*))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.