I never understood the necessary part of the description.
.fetchAll() Selects the specified Parse.Object list.
.fetchAllIfNeeded() Selects the specified Parse.Object list, if necessary.
In what situation can I use this and what exactly determines the need? I feel that this is something super elementary, but I could not find a satisfactory and clear definition.
In an example in the API, I noticed that fetchAllIfNeeded() has:
// Objects were fetched and updated.
If successful, when fetchAll has only:
So fetchAllIfNeeded() also saves stuff? Very confusing here.
UPDATES
TEST 1
Turning to some @danh hints left in the comments, I tried the following things.
var todos = []; var x = new Todo({content:'Test A'});
So, in this case, my client x is different from the server. But x.hasChanged() is incorrect, since we used the set function, and the change event is fired. fetchAllIfNeeded does not return results. Thus, this does not mean that he is trying to compare it directly with what is being synchronized and retrieved on the server.
I noticed that in the request payload, running fetchAllIfNeeded sends the next interesting thing.
{where: {objectId: {$in: []}}, _method: "GET",…}
So it seems like something on the clientide determines if the isNeeded object
Test 2
So, now, based on the comments, I tried to manipulate the changed state of the object, setting it to silent.
x.set({content:'Test C'}, {silent:true}); x.hasChanged();
Still nothing interesting. Obviously, the server state ("Test A") is different from the client ("Test C"). and I still get [] , and the request payload:
{where: {objectId: {$in: []}}, _method: "GET",…}
UPDATE 2
I found this out by looking at the source of Parse. See the answer.