Skip to content

Commit 4776d83

Browse files
committed
wip
1 parent 8decf8d commit 4776d83

File tree

7 files changed

+72
-33
lines changed

7 files changed

+72
-33
lines changed

sqlite-cloud/platform/analyzer.mdx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,19 @@ import applyAnalyzer from '@docs-website-assets/introduction/video/dashboard_ana
1212

1313
The Analyzer panel is a powerful tool that collects and categorizes all the queries executed on your cluster based on their execution time. It allows for intelligent and proactive analysis, and provides recommendations on which indexes to use to optimize frequently used queries.
1414

15-
<VideoPlayer src={enableAnalyzer} />
15+
---
1616

17-
By default, the Analyzer is turned off to avoid a small performance penalty. However, you can enable it by accessing the Settings button and setting the `query_analyzer_enabled` flag to 1, then pressing Save. You can also adjust the `query_analyzer_threshold` flag to set the minimum threshold query time (in milliseconds) that triggers a query to be included in the Analyzer. If the default value is too low, it's recommended to increase it to avoid having too many queries included in the panel.
17+
## Getting Started
1818

19+
By default, the Analyzer is turned off to avoid a small performance penalty. However, you can enable it by accessing the Settings button and setting the `query_analyzer_enabled` flag to 1, then pressing Save. You can also adjust the `query_analyzer_threshold` flag to set the minimum threshold query time (in milliseconds) that triggers a query to be included in the Analyzer. If the default value is too low, it's recommended to increase it to avoid having too many queries included in the panel.
20+
<VideoPlayer src={enableAnalyzer} />
1921

2022

23+
----
2124
## Testing the Analyzer
25+
To test the Analyzer, we can go to the `Studio -> chinook.sqlite -> SQL Console` section and perform a query that filters the non-indexed Composer column of the Track table with the following statement: `SELECT * FROM Tracks WHERE Composer = 'AC/DC'`;
2226
<VideoPlayer src={applyAnalyzer} />
2327

24-
To test the Analyzer, we can go to the `Studio -> chinook.sqlite -> SQL Console` section and perform a query that filters the non-indexed Composer column of the Track table with the following statement: `SELECT * FROM Tracks WHERE Composer = 'AC/DC'`;
2528

2629

2730
Once we have executed this query, we can go back to the Analyzer panel and see that it has been successfully analyzed by the **nxidiwbuhz** node.

sqlite-cloud/platform/backups.mdx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ import VideoPlayer from '@commons-components/Video/VideoPlayer.astro';
1010
import enableDisableBackup from '@docs-website-assets/introduction/video/dashboard_enable_disable_backup.mp4';
1111
import restoreBackup from '@docs-website-assets/introduction/video/dashboard_restore_backup.mp4';
1212

13-
## Overview
1413
Backups provide a robust solution for mitigating data loss and resolving data corruption issues. Backups are available for databases in all [Dev, Pro and Startup](https://www.sqlitecloud.io/pricing) projects.
1514

1615
SQLite Cloud creates a full snapshot backup of your data once a day, and stores incremental changes once per second, on commodity object storage.
1716

17+
----
18+
1819
## Features
1920

2021
#### Automated Backups
@@ -24,13 +25,16 @@ SQLite Cloud creates a full snapshot backup of your data once a day, and stores
2425
- **Easy Restoration Process**: Restoring from a backup automatically overwrites the existing database, seamlessly reverting it to the desired state without additional configuration.
2526
- **Consistency and Reliability**: After restoration, the database functions as it did at the chosen point in time, ensuring operational continuity.
2627

28+
29+
---
30+
2731
## Getting Started
2832
Setting up and managing backups in SQLite Cloud is designed to be straightforward, allowing you to implement robust data protection strategies effortlessly.
2933

3034
<VideoPlayer src={enableDisableBackup} />
3135

32-
33-
### Restoring from a Backup
36+
---
37+
## Restoring from a Backup
3438

3539
Click on a backup to begin the restore process. Select Yes to confirm the restoration, and your database will be restored to the selected point in time.
3640

sqlite-cloud/platform/edge-functions.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Edge functions can be called remotely over HTTP or Websockets via API, or trigge
1818

1919
Turning on linearizable reads ensures strong consistency, but may introduce some latency. When eventual consistency is sufficient, we recommend leaving linearizable reads off.
2020

21+
---
22+
2123
## Getting Started
2224

2325
Use the **Edge Functions panel** to effortlessly create, deploy, and test Edge Functions directly in the SQLite Cloud dashboard.
@@ -67,6 +69,7 @@ Edge functions can be called via HTTP GET and POST methods. You can pass additio
6769
- Query parameters: Accessible via `request.params`
6870
- Request body: Accessible via `request.data`
6971

72+
---
7073

7174
## Guides
7275
### Interacting with your Database
@@ -102,6 +105,9 @@ You can also add environment variables in the UI by navigating to the "Environme
102105
### Handling Errors
103106
In case of error we return an HTTP error code and a JSON with the error message. Manually throwing an error in your code results in a 500 response. You may also return an error.
104107

108+
109+
---
110+
105111
## Examples
106112

107113
### Assigning and Notifying a Support Rep on User Sign up

sqlite-cloud/platform/offsync.mdx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ import enableSync from '@docs-website-assets/introduction/video/dashboard_sqlite
1111
import connectionUrlSync from '@docs-website-assets/introduction/video/dashboard_sync_connection_url.mp4';
1212
import devicesSync from '@docs-website-assets/introduction/video/dashboard_sync_devices.mp4';
1313

14-
15-
1614
import Callout from "@commons-components/Information/Callout.astro";
1715

1816
OffSync is a powerful SQLite Cloud feature that enables true **local-first** data synchronization for your applications. Powered by the [SQLite Sync](https://github.com/sqliteai/sqlite-sync) extension, it allows you to build robust, offline-capable applications where data is stored and processed on edge devices and seamlessly synchronized with a central SQLite Cloud database.
1917

2018
This architecture is ideal for mobile apps, IoT devices, and any application requiring high availability and low latency, even with intermittent network connectivity. By leveraging Conflict-free Replicated Data Types (CRDTs), OffSync ensures that changes made offline are merged automatically and without conflicts when the device reconnects.
2119

20+
21+
---
22+
2223
## How It Works
2324

2425
OffSync extends standard SQLite tables with built-in support for offline work and automatic synchronization. This allows multiple devices to operate independently and then seamlessly merge their changes.
@@ -29,26 +30,29 @@ OffSync extends standard SQLite tables with built-in support for offline work an
2930

3031
When combined with [Row-Level Security (RLS)](/docs/rls), OffSync allows you to build secure, multi-tenant applications where each user's data is safely isolated, both on the edge and in the cloud.
3132

33+
34+
---
35+
3236
## Configuring OffSync
3337

3438
You can enable and manage OffSync for your databases directly from the SQLite Cloud dashboard.
3539
Below are the main steps:
3640

37-
### 1. Enable Tables for Synchronization
41+
### Enable Tables for Synchronization
3842
From the **Sync Tables** tab, select which tables in your database you want to keep synchronized.
3943
Once enabled, all changes to those tables will automatically sync with connected devices.
4044

4145
<VideoPlayer src={enableSync} />
4246

4347

44-
### 2. Get the Connection String
48+
### Get the Connection String
4549
In the **Configuration** tab, copy the connection string.
4650
Use this in your application to initialize OffSync and connect your local SQLite database with SQLite Cloud.
4751

4852
<VideoPlayer src={connectionUrlSync} />
4953

5054

51-
### 3. Manage Connected Devices
55+
### Manage Connected Devices
5256
In the **Devices** tab, you can view all devices currently connected to your database.
5357
Here you can check their sync status and remove devices if needed.
5458

sqlite-cloud/platform/rls.mdx

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import VideoPlayer from '@commons-components/Video/VideoPlayer.astro';
1010
import rlsEnable from '@docs-website-assets/introduction/video/dashboard_rls_enable.mp4';
1111
import rlsTest from '@docs-website-assets/introduction/video/dashboard_rls_test.mp4';
1212

13-
14-
1513
import Callout from "@commons-components/Information/Callout.astro";
1614

1715
Row-Level Security (RLS) allows you to define fine-grained access control policies that determine which rows in a table a user can access. This ensures that users can only view or modify data they are authorized to see, enhancing data security and privacy.
@@ -24,6 +22,8 @@ RLS is a powerful feature for building secure, multi-tenant applications. When c
2422

2523
This architecture simplifies development by allowing your application to interact with a local database while SQLite Cloud [OffSync](/docs/offsync) transparently handles the synchronization with a central database. RLS ensures that each user's data is securely isolated during this process. The centralized database can then be used for powerful business analytics and reporting across all tenants, without compromising individual data privacy.
2624

25+
---
26+
2727
## Policy Enforcement
2828

2929
RLS in SQLite Cloud operates based on the following principles:
@@ -40,6 +40,8 @@ To make data accessible to token-authenticated users, you must both enable RLS f
4040

4141
Otherwise, they will be blocked from accessing any rows.
4242

43+
---
44+
4345
## Configuring RLS
4446

4547
You can configure RLS policies for your databases through the SQLite Cloud dashboard.
@@ -62,7 +64,31 @@ You can configure RLS policies for your databases through the SQLite Cloud dashb
6264
The SQL expressions can be any valid SQLite expression that returns a boolean value. You can use built-in SQLite functions, and even custom functions to define your policies.
6365
</Callout>
6466

67+
### User Information Functions
68+
69+
To help you create dynamic RLS policies, SQLite Cloud provides two functions to retrieve information about the current authenticated user:
70+
71+
- `auth_userid()`: Returns the `userid` of the current token-authenticated user.
72+
- `auth_json()`: Returns a JSON object with all the details of the current token-authenticated user, including `user_id`, `name`, `attributes`, `created_at`, and `expires_at`.
73+
74+
These functions are particularly useful for creating policies that are based on user attributes.
75+
76+
For more information on Access Tokens, see the [Access Tokens documentation](/docs/access-tokens). The API Documentation for the Access Tokens API can be found in the Weblite section in the [Dashboard](https://dashboard.sqlitecloud.io/).
77+
78+
### OLD and NEW References
79+
80+
Your RLS policies for `INSERT`, `UPDATE`, and `DELETE` operations can reference column values as they are being changed. This is done using the special `OLD.column` and `NEW.column` identifiers. Their availability and meaning depend on the operation being performed:
81+
82+
| Operation | `OLD.column` Reference | `NEW.column` Reference |
83+
| :--- | :--- | :--- |
84+
| `INSERT` | Not available | The value for the new row. |
85+
| `UPDATE` | The value of the row *before* the update. | The value of the row *after* the update. |
86+
| `DELETE` | The value of the row being deleted. | Not available |
87+
88+
---
89+
6590
## Testing RLS
91+
6692
<VideoPlayer src={rlsTest} />
6793

6894
To verify that your Row-Level Security (RLS) policies work as expected, you can use the **Test RLS** feature in the dashboard:
@@ -87,26 +113,10 @@ To verify that your Row-Level Security (RLS) policies work as expected, you can
87113
- By switching back to **Database Studio**, you can see all rows in the table without RLS filters.
88114
- This allows you to compare the filtered view (via token) with the complete dataset and confirm that your policies are correctly enforced.
89115

90-
### User Information Functions
91116

92-
To help you create dynamic RLS policies, SQLite Cloud provides two functions to retrieve information about the current authenticated user:
93117

94-
- `auth_userid()`: Returns the `userid` of the current token-authenticated user.
95-
- `auth_json()`: Returns a JSON object with all the details of the current token-authenticated user, including `user_id`, `name`, `attributes`, `created_at`, and `expires_at`.
96-
97-
These functions are particularly useful for creating policies that are based on user attributes.
98-
99-
For more information on Access Tokens, see the [Access Tokens documentation](/docs/access-tokens). The API Documentation for the Access Tokens API can be found in the Weblite section in the [Dashboard](https://dashboard.sqlitecloud.io/).
100118

101-
### OLD and NEW References
102-
103-
Your RLS policies for `INSERT`, `UPDATE`, and `DELETE` operations can reference column values as they are being changed. This is done using the special `OLD.column` and `NEW.column` identifiers. Their availability and meaning depend on the operation being performed:
104-
105-
| Operation | `OLD.column` Reference | `NEW.column` Reference |
106-
| :--- | :--- | :--- |
107-
| `INSERT` | Not available | The value for the new row. |
108-
| `UPDATE` | The value of the row *before* the update. | The value of the row *after* the update. |
109-
| `DELETE` | The value of the row being deleted. | Not available |
119+
---
110120

111121
## Example
112122

@@ -245,7 +255,10 @@ OLD.status <> 'paid'
245255
**Explanation:**
246256
This policy uses the `OLD` reference to check the value of the `status` column *before* the update is applied. If the status is already `'paid'`, the condition `OLD.status <> 'paid'` will be false, and the `UPDATE` operation will be denied. This effectively makes paid invoices read-only.
247257

248-
### Advanced: RLS and SQLite Sync
258+
259+
---
260+
261+
## Advanced: RLS and SQLite Sync
249262

250263
When using RLS in conjunction with [SQLite Sync](https://github.com/sqliteai/sqlite-sync), it's important to understand how they interact. The Sync protocol applies changes on a column-by-column basis, which can affect how `INSERT` and `UPDATE` policies are evaluated.
251264

sqlite-cloud/platform/security.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ To add new users to your cluster, simply click on the **Create User** button.
1515

1616
Once a user is successfully created, you can assign one or more roles to them to determine their level of access to the system.
1717

18+
---
19+
1820
## Roles
1921
In SQLite Cloud, a role is a set of permissions that allows a user to perform specific actions on a particular resource, such as a database or table. Users can have multiple roles, which determine their access to the system.
2022

@@ -29,7 +31,7 @@ There are two types of roles in SQLite Cloud:
2931

3032
![Dashboard Roles](@docs-website-assets/introduction/dashboard_roles.png)
3133

32-
## Built-in roles
34+
### Built-in roles
3335
import Callout from "@commons-components/Information/Callout.astro";
3436

3537
SQLite Cloud offers a comprehensive system of built-in roles designed to provide essential privileges within a database framework. These roles can be assigned using the [GRANT ROLE](https://docs.sqlitecloud.io/docs/role-commands) command, and custom roles can be created with the [CREATE ROLE](https://docs.sqlitecloud.io/docs/role-commands) command. Privileges represent fundamental operations that can be executed on specific databases or tables and can be granted, revoked, or assigned to specific roles.

sqlite-cloud/platform/webhooks.mdx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import webhooksEdgeFunction from '@docs-website-assets/introduction/video/dashbo
1111

1212
**Webhooks** are HTTP callbacks that allow your applications to receive real-time notifications when specific events occur. In the context of SQLite Cloud, webhooks make it easy to build reactive systems by automatically sending notifications when data changes happen within your databases.
1313

14+
15+
---
16+
17+
1418
## Real-Time Notifications for Database Writes
1519

1620

@@ -20,7 +24,7 @@ For example, you can configure SQLite Cloud to notify a [webhook.site](https://w
2024

2125
<VideoPlayer src={webhooksUrl} />
2226

23-
27+
---
2428

2529
## Change Data Capture
2630

@@ -64,12 +68,15 @@ This enables seamless integration with logging systems, monitoring dashboards, o
6468
* **data** – The values corresponding to the affected row(s).
6569
* **webhook** – Metadata about the webhook itself, including its unique `id`, target `action` (URL or Edge Function), and configuration `options`.
6670

71+
---
72+
6773
## Security
6874

6975
Upon creation, each webhook is assigned a **secret key** used to verify the authenticity of incoming requests.
7076

7177
![Dashboard Projects](@docs-website-assets/introduction/dashboard_webhook_secret.png)
7278

79+
---
7380

7481
## Trigger Edge Functions
7582

0 commit comments

Comments
 (0)