ios - Getting the most recent record for each unique user in Parse using PFQuery -
i'm using parse.com, , have 2 classes: user , report. user may issue several reports during day, i'm interested in recent one. however, need reports meet specific criteria, recent one.
the end result array of reports, user unique on each one, this:
objectid | reportedvalue | user | createdat 1234 | 100 | aaaa | 2013-05-20t04:23:41.907z 1235 | 100 | bbbb | 2013-04-29t05:10:41.907z 1236 | 100 | cccc | 2013-05-20t02:14:41.907z 1237 | 100 | dddd | 2013-05-19t04:03:41.907z so, user aaaa might have 20 reports, need recent, each user. however, i'm searching based on reportedvalue being 100, , desired result report objects, not user, i'd prefer not go through every user.
is possible in parse?
consider using object in data model assist this. container relationship report. when new report saved, bit of cloud code runs which:
- finds previous latest
reportassociated user - removes report container relation
- adds new report container relation
working way, app can make single, simple, query on relation of latest reports.
Comments
Post a Comment