I have the following query:
@Query(value = "{ '_id': { \$in : ?0 } }", fields = "{ 'ids': '\$_id', '_id': 0 }")
fun findExistingIds(ids: Set<ObjectId>): Mono<ExistingIds>
The ExistingIds
is a class that contains a List of Strings:
data class ExistingIds(val ids: List<String>)
What I want to achieve is the above query to return a list of the existing ids, but instead it returns the ids separately and not all in one. (And thats the reason I get the following exception)
Caused by: org.springframework.dao.IncorrectResultSizeDataAccessException: Query {...} returned non unique result.
I tested the query on Mongo Compass as well and this is the result
I also tried to have it as an array but again it creates separate arrays as
Any idea how I can solve this? Thank you very much for your time and help!