• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with cdb_sync - What is the local table?
#1
I am not understanding cdb_sync. This is really the only function that I do not understand and I believe it is probably the most useful of them all. So any help would be greatly appreciated! 

In the documentation for the command, it says:

--
Summary

This function will sync all records in a specified table between local and cloud. 
--

My question is: What is a local table? Is this a field or datagrid on a card? Do I export this table from the cloud to my local Livecode project? Or, do I create this local table from scratch and, if so, do all rows and columns have to match? I guess what I am asking is what constitutes a local table?


Many thanks in advance!
  Reply
#2
Hi JereMiami,

A table is just an internal container for a collection of records. Tables exist both on the device, "local", and on the cloud, "cloud". Records can be in a "local" table, a "cloud" table, or both. A table can be created through LCM or with cdb_createTable.

A lot of the APIs have a pTarget parameter that can either be "local" or "cloud", this specifies whether the API should be performed on a "local" table or a table on the "cloud". Let's use cdb_create(pDataA, pTable, pTarget, pInternalA) and cdb_update pDataA, pTable, pRecordID, pTarget, pInternalA as an example.

If we pass "local" to cdb_create, the record will be stored on the device itself. If we pass "cloud", the record will be sent to our servers where it'll be stored. If we create a record on the cloud, there is no "local" record. This means that if we want to update the record, we need to pass "cloud" to cdb_update as well so the record on the cloud can be updated.

cdb_sync can copy the record from the "cloud" table to the "local" table. This allows us to modify the record on the device, without the need to wait for a network transaction. This means we can modify the "local" record all we want, faster than modifying the "cloud" record since there is no wait, then copy it back to the cloud using cdb_sync again when we choose to.

Sorry for the long response. Hopefully I answered your questions. Let me know if you need further clarification.
  Reply
#3
Excellent response. Thank you!
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)