LiveCloud Forums
tip needed on working with data locally - Printable Version

+- LiveCloud Forums (https://forums.livecloud.io)
+-- Forum: General (https://forums.livecloud.io/forumdisplay.php?fid=1)
+--- Forum: General (https://forums.livecloud.io/forumdisplay.php?fid=3)
+--- Thread: tip needed on working with data locally (/showthread.php?tid=102)



tip needed on working with data locally - sltfn - 08-27-2019

Hi. I'm full of questions and have appreciated several helpful answers so far.

To speed processing I'm trying to reduce the number of queries to the cloud my app needs to make. So I'd like to query, retain the data locally temporarily and make further queries to local. Then at end of session update any records that have changed to the cloud. I've wondered about three approaches I hope could work.

1) I make this query.

cdb_batchQuery(tInputA,"cloud","logicalAND","recordData") into tOutputA

Can tOutputA be queried and updated as if it were a table? If so, what's the syntax?

2) If what I've suggested above isn't possible, what is the syntax to populate the data in tOutputA to a local table?

Is put cdb_batchCreate(tInputA, "local") into tOutputB sufficient or are steps required before that command to create a new table?

3) I am aware of the cdb_loadTable command, but I would greatly prefer not to load the entire table, but instead a subset of the table's contents defined by a query. Is that doable?

I imagine there are good solutions available. What are they? Thanks in advance!


RE: tip needed on working with data locally - efrain.c - 08-28-2019

Hi sltfn,

You can use sync to download a table to your device and make it available locally. This will allow you to perform all the same APIs on the data without having to make cloud calls. Then at the end of the session you can sync the table back up to the cloud and any changes (new records, records deleted, records updated, etc) will be made to the cloud.

cdb_sync(pRecordIDL, pTable, pSource, pAllowDeletes, pDetectCollisions)

You mentioned you would prefer a subset of the table instead of the entire table. To do this, pRecordIDL will be a line delimited list of recordIDs corresponding to the subset of the table you are interested in. Once the table is local, you just need to pass "local" instead of "cloud" to the APIs and no more cloud calls.

Hope this helps. Let me know if you have any questions.