In my Scala Application, I am trying to find()
all Objects for a List of ObjectId
s.
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))
.
Unfortunately, parents
will be empty. I have searched the Internet for a in("_id", List[ObjectId])
-Example, but couldn't find a single one.
Reading the documentation , it seems like it is not supported to check for lists, but only for TItem*
. Is it possible to achieve a "is in List" Check somehow?
以varargs的形式传入List
:
Parents.find(in("_id", foundChild.parents: _*))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.