Sunday, 15 September 2013

spring mongodb: getting sorted and paginated list of inner document

spring mongodb: getting sorted and paginated list of inner document

I have two document. User and Activities. Activities is a inner document.
@Document(collection="users")
public class User {
@Id
private String id;
private String usertoken;
private String firstname;
private List<Activity> activities;
}
@Document
public class Activity {
private Date date;
private String text;
}
I am using spring mongo layer in my project. I wanted to query and get a
paginated list of activities (in descending order of date) for a given
user using query annotations. How could I achieve this?
@Query()
List<Activities> getActivities(usertoken, Pageable);
I am fine with getting User document with inner document activities if the
above is not possible.

No comments:

Post a Comment