- Local-only tables: Store data in tables that do not record writes in the upload queue. Copy the data to synced tables when the user registers.
- Clearing the upload queue: Store data in synced tables and delete the upload queue periodically.
Local-Only Tables
The client SDK does not place writes to local-only tables in the upload queue, so the queue does not grow. Store data in local-only tables until the user registers or signs in. To define a local-only table, mark it as local-only in your client schema:Moving Data to Synced Tables
Define each local-only table and its synced counterpart as separate tables in your schema, for examplelocal_lists and lists. When the user registers or signs in, run these statements in one write transaction:
? parameter sets owner_id to the ID of the signed-in user. The inserts place the rows in the upload queue, and the client SDK uploads them to your backend.
To keep the same table name in app queries before and after registration, use the viewName option:
- Before registration, set the view name of the local-only table to
lists. Give the synced table an unused view name, such asinactive_synced_lists. - When the user registers, update the schema so that the synced table uses the view name
lists. Give the local-only table an unused view name, such asinactive_local_lists. - Copy the data with the statements above. Replace
local_listswithinactive_local_listsin both statements.
updateSchema():
If you use Drift with local-only tables that override
viewName, Drift’s watch streams may not update. See the Drift troubleshooting guide for the fix.Clearing the Upload Queue
If you store data in synced tables, you can delete the upload queue periodically, for example on every app start:ps_updated_rows table for each row written locally. Do not delete these entries. When the app syncs, the client SDK uses them to find local rows that are missing from the synced data and removes those rows. Without these entries, such rows stay on the device. If this overhead is too large for your app, use local-only tables instead.