I have a Post document in Mongo DB, which has an array of comments.
class Post {
String id,
User user,
List<Comments> comments
}
The class structure looks as above.
Now I would like to use mongoTemplate in order to retrieve a sliced content of the comments.
Lets say there are thousands of comments, I would like to get sliced results for this NESTED ARRAY. Just to clarify, I am not looking for Paginated(OR Sliced) result of the Posts (which the ROOT document).
The query is supported by mongo, but I could not form a query from java using spring boot. https://docs.mongodb.com/manual/reference/operator/projection/slice/
How to simulate the above query using Spring Boot 2.0.0 and MongoTemplate?