In the chapter "Local data warehouse" from "Pin and fromlocaldatastore"

Like the name, I want to ask what is the difference between

fromPin() 

and

 fromLocalDatastore() 

By the way, Pin and datastore are two terminologies. What is the difference between the two of them?

Thanks.

+7
source share
1 answer

There is a slight difference, and you can see it from the documents and the decompiled code of the Parse library (well, this last one is more complicated ...).

The docs say:

fromLocalDatastore (): change the source of this request to all pinned objects.

fromPin (): Change the source of this request to a group of pinned objects by default.

Here you can see that during Interse Parse there is a way to get all the objects from the entire set of pinned data without filters, but also from the so-called "default group". This group is defined in Parse code with the following line: _default (o'rly?).

When you write something using pinInBackground, you can do it differently:

pinInBackground () [no arguments]: stores the object and each object that it points to in the local data store.

This is what the docs say, but if you look at the code, you will find that the output will actually be done ... _default group!

 public Task<Void> pinInBackground() { return pinAllInBackground("_default", Arrays.asList(new ParseObject[] { this })); } 

Alternatively, you can always call pinInBackground(String group) to specify the exact group.

Conclusion: every time you bind an object, it is guaranteed to bind to a specific group. The "_default" group if you do not specify anything in the parameters. If you attach the object to your "G" group, then a query using fromPin() will not find it! Because you did not put it on "_default", but "G".

Instead, using fromLocalDatastore() , the query will be guaranteed to find your object, because it will search in "_default", "G", etc.

+11
source share

All Articles