You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Description:**Checks if there are any local changes that have not yet been sent to the remote server.
362
+
**Description:**Sends all unsent local changes to the remote server.
363
363
364
364
**Parameters:** None.
365
365
366
-
**Returns:** 1 if there are unsent changes, 0 otherwise.
367
-
368
-
**Example:**
366
+
**Returns:** A JSON string with the sync status:
369
367
370
-
```sql
371
-
SELECT cloudsync_network_has_unsent_changes();
368
+
```json
369
+
{"status":"synced|syncing|out-of-sync|error", "localVersion": N, "serverVersion": N}
372
370
```
373
371
374
-
---
375
-
376
-
### `cloudsync_network_send_changes()`
377
-
378
-
**Description:** Sends all unsent local changes to the remote server.
379
-
380
-
**Parameters:** None.
381
-
382
-
**Returns:** None.
372
+
-`status`: The current sync state — `"synced"` (all changes confirmed), `"syncing"` (changes sent but not yet confirmed), `"out-of-sync"` (local changes pending or gaps detected), or `"error"`.
373
+
-`localVersion`: The latest local database version.
374
+
-`serverVersion`: The latest version confirmed by the server.
**Description:** Checks if there are any local changes that have not yet been sent to the remote server.
470
+
471
+
**Parameters:** None.
472
+
473
+
**Returns:** 1 if there are unsent changes, 0 otherwise.
474
+
475
+
**Example:**
476
+
477
+
```sql
478
+
SELECT cloudsync_network_has_unsent_changes();
479
+
```
480
+
481
+
---
482
+
458
483
### `cloudsync_network_logout()`
459
484
460
-
**Description:** Logs out the current user and cleans up all local data from synchronized tables. This function deletes and then re-initializes synchronized tables, useful for switching users or resetting the local database. **Warning:** This function deletes all data from synchronized tables. Use with caution.
485
+
**Description:** Logs out the current user and cleans up all local data from synchronized tables. This function deletes and then re-initializes synchronized tables, useful for switching users or resetting the local database. **Warning:** This function deletes all data from synchronized tables. Use with caution. Consider calling [`cloudsync_network_has_unsent_changes()`](#cloudsync_network_has_unsent_changes) before logout to check for unsent local changes and warn the user before data that has not been fully synchronized to the remote server is deleted.
Copy file name to clipboardExpand all lines: README.md
+22-19Lines changed: 22 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,21 +50,24 @@ The sync layer is tightly integrated with [**SQLite Cloud**](https://sqlitecloud
50
50
51
51
## Row-Level Security
52
52
53
-
Thanks to the underlying SQLite Cloud infrastructure, **SQLite Sync supports Row-Level Security (RLS)**—allowing you to define **precise access control at the row level**:
53
+
Thanks to the underlying SQLite Cloud infrastructure, **SQLite Sync supports Row-Level Security (RLS)**—allowing you to use a **single shared cloud database** while each client only sees and modifies its own data. RLS policies are enforced on the server, so the security boundary is at the database level, not in application code.
54
54
55
55
- Control not just who can read or write a table, but **which specific rows** they can access.
56
-
-Enforce security policies on the server—no need for client-side filtering.
56
+
-Each device syncs only the rows it is authorized to see—no full dataset download, no client-side filtering.
57
57
58
58
For example:
59
59
60
60
- User A can only see and edit their own data.
61
61
- User B can access a different set of rows—even within the same shared table.
62
62
63
-
**Benefits of RLS**:
63
+
**Benefits**:
64
64
65
-
-**Data isolation**: Ensure users only access what they’re authorized to see.
66
-
-**Built-in privacy**: Security policies are enforced at the database level.
67
-
-**Simplified development**: Reduce or eliminate complex permission logic in your application code.
65
+
-**Single database, multiple tenants**: One cloud database serves all users. RLS policies partition data per user or role, eliminating the need to provision separate databases.
66
+
-**Efficient sync**: Each client downloads only its authorized rows, reducing bandwidth and local storage.
67
+
-**Server-enforced security**: Policies are evaluated on the server during sync. A compromised or modified client cannot bypass access controls.
68
+
-**Simplified development**: No need to implement permission logic in your application—define policies once in the database and they apply everywhere.
69
+
70
+
For more information, see the [SQLite Cloud RLS documentation](https://docs.sqlitecloud.io/docs/rls).
68
71
69
72
### What Can You Build with SQLite Sync?
70
73
@@ -102,7 +105,12 @@ SQLite Sync is ideal for building collaborative and distributed apps across web,
102
105
103
106
## Documentation
104
107
105
-
For detailed information on all available functions, their parameters, and examples, refer to the [comprehensive API Reference](./API.md).
108
+
For detailed information on all available functions, their parameters, and examples, refer to the [comprehensive API Reference](./API.md). The API includes:
109
+
110
+
-**Configuration Functions** — initialize, enable, and disable sync on tables
111
+
-**Helper Functions** — version info, site IDs, UUID generation
112
+
-**Schema Alteration Functions** — safely alter synced tables
113
+
-**Network Functions** — connect, authenticate, send/receive changes, and monitor sync status
--Repeat — check rowsReceived in the JSON result to see if data was received
320
329
SELECT cloudsync_network_sync();
321
330
322
331
-- View synchronized data
@@ -454,12 +463,6 @@ Be aware that certain types of triggers can cause errors during synchronization
454
463
- If a trigger modifies a table that is also synchronized with SQLite Sync, changes performed by the trigger may be applied twice during the merge operation
455
464
- This can lead to constraint violations or unexpected data states depending on the table's constraints
456
465
457
-
**Column-by-Column Processing**
458
-
- SQLite Sync applies changes column-by-column during synchronization
459
-
- UPDATE triggers may be called multiple times for a single row as each column is processed
0 commit comments