iosobjective-ccocoa-touchcustom-backend

Get latest inserted object FatFractal


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];

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.