我希望得到Invitation
的最后10个对象,其中Event.date
按降序排序
我这样做,但它不起作用:
ParseObject parseUser = user;
ParseQuery eventQuery = ParseQuery.getQuery("Event");
eventQuery.whereLessThan("date", new Date());
eventQuery.orderByDescending("date");
eventQuery.setLimit(10);
ParseQuery<ParseObject> invitationQuery = ParseQuery.getQuery("Invitation");
invitationQuery.whereEqualTo("user", parseUser);
invitationQuery.whereMatchesQuery("event", eventQuery);
List<ParseObject> list= invitationQuery.find();
答案 0 :(得分:1)
试试这个: 尝试查看前10个事件的第一个查询。然后对邀请执行一个新查询,其中事件是您在第一个查询中找到的ID之一
ParseQuery eventQuery = ParseQuery.getQuery("Event");
eventQuery.whereLessThan("date", new Date());
eventQuery.orderByDescending("date");
eventQuery.setLimit(10);
eventQuery.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> objects, ParseException e) {
ArrayList<ParseObject> eventsIds = new ArrayList<ParseObject>();
if (e == null) {
for (ParseObject event : objects) {
eventsIds.add(ParseObject.creatWithoutData("event",event.getObjectId()));
}
ParseQuery<ParseObject> invitationQuery = ParseQuery.getQuery("Invitation");
invitationQuery.whereEqualTo("user", parseUser);
invitationQuery.whereContainedIn("event", eventIds);
invitationQuery.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> objects, ParseException e) {
//Do whatever you want with your events
}
}
});
}
});