In Parse, can I force related ParseObjects to get fetched? - android

In the Parse android docs it says that by default, related ParsePbjects are not fetched, implying that there is a setting that will fetch them. It later says that they cannot be fetched without a call to fetchIfNeeded. Which is it? I definitely need to fetch the related ParseObject and would prefer to do so without having to make multiple requests. Is that possible?
By default, when fetching an object, related ParseObjects are not fetched. These objects' values cannot be retrieved until they have been fetched like so:

In the ParseQuery you are using to get the original object, you can use the include(key) method to tell it to also fetch the related object. This works for pointers and arrays of pointers.

No They Can't. I am also facing the similar problem. SO if you have two table and one table is having reference key from second table, then there is no such query where we can find relative data.
Its Sad. I wonder why they don't provide such a useful thing.

Related

How do I handle updated data in an API after local data persistence?

I have a REST API containing a JSON Array of JSON Objects.
On the first launch of the Android application, the data is consumed through retrofit and stored using a Room database.
My question is: what do I do on the second launch? Do I systematically call and consume the API after each launch? Or is there a better way of handling this?
Thanks in advance
You don't have to consume the API call if you stored that data already, what you can do is defining a timestamp variable inside your model class, and put any time value (you can add days or months) that should determine whether your app should fetch the data or not, if the time does't pass yet you can get the data from your local database, android documentation recommend using NetworkBoundResource to handle this case, check it out it will help you a lot.

Saving Revision in Cloudant Sync as an ordered LinkedHashMap, but not keeping the field's order in the server database (Cloudant), after replication

This is the inspection of the Revision object, with the LinkedHashMap correctly ordered
After saving it, if I retrieve the same document, I get this.
The 'body' field of the 'retrieved' object appears to be correctly ordered,
but if I get it as a Map, the map is disordered.
This is not a big deal to me but I have notice that after replication, the document is saved in the server with the same order that the disordered map I have retrieved on the app.
I really want to have the document correctly ordered on the server for readably purposes, is it possible?
I'm running my code on Android 6.0, even though, may this issue be related to the following link? LinkedHashMap entrySet's order not being preserved in a stream (Android)
Thanks for your help!
When you use the asMap method on a document object, Sync Android creates a shallow-copy Hashmap (see here). So that's why the Map retrieved from the local revision isn't ordered.
It looks like, deep in the depths, and don't quote me on it as it's a long time since I looked at this code, asMap is used to get the JSON to upload, meaning that unordered Map is used to create the JSON that's uploaded to Couch/Cloudant. (See here, but frankly this is deep in the guts after following quite a code path so probably not super-useful).
I think ordering on Java HashMaps depends on insertion order, which would explain why the order is the same on the server as for the asMap result from the local document object.

How to get data from SQLite database using GreenDao

I am using greendao for the first time. and it is going good. I have generated code and entities. I have put the basic data and checked it using sqlite browser and all data is there in specific fields.
Now there are some method in the dao class and I have used the insert method to insert the data. But Now I have to get data so looking how to return the data.
here are my some of the questions:
How to get data ?
Is there any built in method in there ? or I need to make my own and where?
I need to know when should I need to close connection and what things I need to take in account while using greendao ?
please provide some source code or any demo code on How I can get data. I have no source code to share on , As rest is basic code generated by the dao. And I think it would be childish question , but I have not found any documentation telling about its method it have etc. Please help me in my problem described above and also clear my confusions.
To retrieve your data you have to use greenDao Queries. You can specify your own conditions to match rows.
Example (extracted from docs):
List joes = userDao.queryBuilder()
.where(Properties.FirstName.eq("Joe"))
.orderAsc(Properties.LastName)
.list();
Here is the docs (with demos): http://greenrobot.org/greendao/documentation/queries/

A check before saving to the Cloud Parse

I want to do a check on the cloud first before I save the data. For example...
Do a query to check if a Task name and User situated to it is there.
If there is update it.
If not save to the cloud.
I'm having the issue with checking with two params like you could with SQLite on Android.
Any Ideas?
Thank you
Just call whereEqualTo multiple times to add more constraints to the query.

Parse objects overriding when using Local Datastore

I'm facing a weird issue using Parse's Local Datastore.
I have a Cloud function declared in backend that returns a list of ParseUsers, which can returns my current User.
The problem is when the function returns my User in the list, local currentUser gets overrided by the server data, resulting in a lost of information (i.e. authData).
Reading documentation from Parse I found this:
There are a couple of side effects of enabling the local datastore
that you should be aware of. When enabled, there will only be one
instance of any given ParseObject. For example, imagine you have an
instance of the "GameScore" class with an objectId of "xWMyZ4YEGZ",
and then you issue a ParseQuery for all instances of "GameScore" with
that objectId. The result will be the same instance of the object you
already have in memory.
I think this may be causing the problem.
Have you got any idea how to prevent this behaviour?
Thanks you in advance.
Well I finally found that this is due to a know Bug: https://developers.facebook.com/bugs/898928300168631/?search_id

Categories

Resources