Reputation: 6611
I am trying to pass multiples value in $in
query using Query DSL
with Reactive Mongo Extensions. But the result is empty list. Follwoing is my Code:
def findUsersByRolesIds(rolesIds: List[BSONObjectID], page: Int, pageSize: Int): Future[List[User]] = {
logger.info("findUsersByRolesIds Reactive Repository Method");
userGenericRepo.find($doc("userRoles._id" $in (rolesIds)), $doc("createdOn" -> -1 ), page, pageSize);
}
When i am trying to execute above code, the result was empty.
But when i pass, below code the result was return.
def findUsersByRolesIds(rolesIds: List[BSONObjectID], page: Int, pageSize: Int): Future[List[User]] = {
logger.info("findUsersByRolesIds Reactive Repository Method");
userGenericRepo.find($doc("userRoles._id" $in (BSONObjectID.apply("5548b098b964e7039852ff58"))), $doc("createdOn" -> -1 ), page, pageSize);
}
The main problem is that, i have multiple value, so that's why i create the list but here the list is not working. How this query is possible with reactive mongo extenstions
and Query DSL
.
Upvotes: 0
Views: 439
Reputation: 1006
$in expects varargs, ie val dsl: BSONDocument = "age" $in (1, 2, 3)
. So you cannot directly pass a collection to it. Try using this "age" $in (rolesIds: _*)
.
Upvotes: 2