4
votes

I have a Meal object that stores pointers to n created objects "FoodInfo" using the key "MealItems".

When I query for the meal I take advantage of the [query includeKey:@"MealItems"] to fetch the items pointed to while fetching the "Meal".

This works swimmingly if the objects are created while online (ie. all are stored in the cloud db).

However, since I cannot assume access to the cloud at all time for this app I am now trying to enable the local datastore so I've changed my queries to use: [query fromLocalDatastore];

and I've changed all of my objects' save methods to pinInBackgroundWithBlock followed by (assuming success of local save) saveInBackgroundWithBlock followed by (assuming failure) saveEventually.

To test this, I:

  • turned off wifi
  • ran the code to create a meal and then add newly created foods to it. This works with no error codes.
  • ran a report that then queries for the meal just created. This fails with the following:
Error: Error Domain=Parse Code=121 
"include is invalid for non-ParseObjects" UserInfo=0x60800007f400 {
    error=include is invalid for non-ParseObjects, 
    NSLocalizedDescription=include is invalid for non-ParseObjects, 
    code=121
} {
    NSLocalizedDescription = "include is invalid for non-ParseObjects";
    code = 121;
    error = "include is invalid for non-ParseObjects";
}

Is this scenario not supported?

When I re-enable wifi, the meal is successfully added to the online db, but the query failure still happens when I run the query with the includeKey locally.

Am I missing something here? I'm quite surprised to see this failing. It seems like a really basic feature that should work whether local or cloud based.

1
Show the code you're using for the test - Wain
The fundamental question shouldn't require showing code. It is clearly possible to create an object A that contains an array of pointers to other objects and pin them all to the local datastore while offline. Does parse support a local datastore query that retrieves A and the objects pointed to in the array via includekey prior to any of the objects being saved over the network? - Gerald
Wondering if this was addressed on any of the newer versions or if you would mind to share your workaround if any @Gerald. Thanks - Jaime Agudo

1 Answers

0
votes

Parse objects are not created until you save them. Try using saveEventually first before using pinInBackgroundWithBlock.