Question

I'm using FatFractal for my backend in a iPhone-app. Been searching the web and FatFractal docs without any luck. I want to retrieve the latest object in a collection from a grabbag:

NSArray *result = [[Store ff] grabBagGetAllForObj:thread grabBagName:@"messages" withQuery:@"Get the latest inserted object" error:&err];
Was it helpful?

Solution

Probably the best way to do this is to construct the full query yourself and then use the standard getArrayFromUri: method. Taking your example, this would look like:

FatFractal *ff = [Store ff];
NSString *query = [NSString stringWithFormat:
                   @"%@/messages?sort=createdAt desc&start=0&count=1",
                   [ff metaDataForObj:thread].ffUrl];
NSArray *result = [ff getArrayFromUri:query];

For more info, see http://fatfractal.com/prod/docs/queries/#sorting-and-limiting-results.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top