mercredi 6 mai 2015

Using Entity Primary Key from server on the client

I am starting to build the client side database for my app. Basically I want to cache server data to minimize the payload to the server. In the end, a lot of calls should vanish to sending a time stamp to the server to ask if the local data is still valid and only if the time stamp is out-dated the whole data gets transferred.

The thing is that I am not sure if I should/could do something like this:

Entity language = schema.addEntity("Language");
language.addLongProperty("languageServerID").primaryKey(); // Store ID from the server
language.addStringProperty("languageCode");
language.addStringProperty("languageName");

instead of:

Entity language = schema.addEntity("Language");
language.addIdProperty();                           // Generate ID Property
language.addLongProperty("languageServerID");       // ID from the server for entity comparison
language.addStringProperty("languageCode");
language.addStringProperty("languageName");

Note that every entity would then rely on the IDs from the server e.g. if a Person has an Address, then on the client device they would be linked through IDs entirely coming from the server - which indeed does sound a little scary to me ..

So, should I do that or is that a very bad solution?

Aucun commentaire:

Enregistrer un commentaire