0

The problem is that I want to get all of the objectIDs and I want to minimize data transfer in-between the server and iOS app. So, let's say I have a dozen of thousands of PFObjects on PARSE, they are updated and deleted and my app needs to update its knowledge about what objects are present on PARSE without using push-notifications (I am handling such a case when user disallows them). I can not just load all of the PFObjects every time my UIViewController presents data, retrieve PFObjects' ids and start checking whether my local store (not PARSE Local Datastore, different one) has such ids, since PFObjects themselves are large and there is a plenty of them, but it is ok for me to just load all of the objectIds. So, how to do this, and is it possible at all?

Some method of PFQuery like getAllObjectIds would be very helpful, but there seems to be no such methods.

2 Answers 2

1

You can solve the Add and Update situation but for the Delete its easier t use the straightforward solution and periodically request all object. Here is a solution for the Update/Add object case:

and save the most recentUpdated Date In the first request to parse set order object by updatedAt:

[query orderByDescending:@"updatedAt"];//orderByDescending

For any futur query set greaterThan:mostRecentUpdatedAt to get only updated and added objects:

if ([[NSUserDefaults standardUserDefaults] objectForKey:@"mostRecentUpdatedAt"]){
    NSDate* mostRecentUpdatedAt = [[NSUserDefaults standardUserDefaults] objectForKey:@"mostRecentUpdatedAt"];

    [query whereKey:@"updatedAt" greaterThan:mostRecentUpdatedAt];
}

save mostRecentUpdatedAt for futur queries:

if (results.count) {

    PFObject* firtObj = [results firstObject];
    NSDate* mostRecentUpdatedAt =  firtObj.updatedAt;
    [[NSUserDefaults standardUserDefaults] setObject:mostRecentUpdatedAt forKey:@"mostRecentUpdatedAt"];
    [[NSUserDefaults standardUserDefaults] synchronize];

}

For the Delete case you need a request to count the number or objects and compared to your count. this should be done immediately after checking for add/update since in this case if count mismatch then there is a delete situation. then get all objects again (no magic to be done to identify the deleted object since its already deleted!!).

Sign up to request clarification or add additional context in comments.

Comments

0

You can not query the Parse DB for just the objectId's. You would have to pull the entire PFObject and then loop through and store just the id's and discard the rest.

Alternatively, I think you could create a PFRelation from the objects that you are interested in and the user to track just those objects.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.