I wanted to achieve something similar to contains all
, but I couldn't find any support for mongodb - $all, so I tried to do this by hand.
My entity has a simple set of tags
- Set<String>
.
val taskEntity = QTaskEntity.taskEntity
val where = BooleanBuilder()
where.and(taskEntity.tags.contains("a"))
where.and(taskEntity.tags.contains("b"))
But the generated query only takes b
into consideration, a
is completely ignored.
find using query: { "tags" : "b" }...
What's more: I also have another filter to find tasks
that have any of the specified tags
(contains any
) - it works by using mongodb $in
as expected:
where.and(taskEntity.tags.any().`in`(["a", "b"])))
...
find using query: { "tags" : { "$in" : ["a", "b"] } }
But if I combine both of those then the contains any
is ignored and the result is the same as with the first snippet.
Am I doing something wrong here or is this a bug or something that cannot be done on mongodb side? Could kotlin be at fault here (generated classes look fine to me)? Is this something that can be done in mongodb only through the $all
mentioned before and querydsl doesn't support it?