Skip to content

Commit 8decf8d

Browse files
committed
wip
1 parent 0f36519 commit 8decf8d

File tree

6 files changed

+154
-71
lines changed

6 files changed

+154
-71
lines changed

sqlite-cloud/create-database.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,19 @@ To upload a local SQLite database via the SQLite Cloud UI, navigate to the Datab
3131
### Via Dashboard UI
3232
To import a database from the UI, navigate to the Databases tab and click the "Upload Database" button.
3333

34+
Select the database file you want to upload, and click "Upload Database". The database will be available in your cluster within a few minutes.
35+
3436
<VideoPlayer src={uploadDb} />
3537

36-
Select the database file you want to upload, and click "Upload Database". The database will be available in your cluster within a few minutes.
3738

3839
## Creating a new database
3940
### From the Dashboard
4041

4142
To create a new database from the SQLite Cloud UI, navigate to the Databases tab and click the "Create Database" button.
42-
<VideoPlayer src={createDb} />
4343

4444
The default encoding is set to UTF-8, and the default page size is 4096KB.
45+
<VideoPlayer src={createDb} />
46+
4547

4648
### From the API
4749
To create a new database or upload an existing database via [Weblite](/docs/weblite), our REST API, you can make a request with the following parameters:

sqlite-cloud/platform/analyzer.mdx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,29 @@ category: platform
55
status: publish
66
slug: analyzer
77
---
8+
import VideoPlayer from '@commons-components/Video/VideoPlayer.astro';
9+
import enableAnalyzer from '@docs-website-assets/introduction/video/dashboard_enable_query_analyzer.mp4';
10+
import applyAnalyzer from '@docs-website-assets/introduction/video/dashboard_analyzer_apply_suggestion.mp4';
11+
812

913
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.
1014

11-
![Dashboard Empty Analyzer](@docs-website-assets/introduction/dashboard_analyzer_empty.png)
15+
<VideoPlayer src={enableAnalyzer} />
1216

1317
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.
1418

15-
![Dashboard Analyzer Settings](@docs-website-assets/introduction/dashboard_analyzer_settings.png)
1619

17-
To test the Analyzer, we can go to the `Databases -> Chinook.sqlite -> 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'`;
1820

19-
![Dashboard Analyzer Console](@docs-website-assets/introduction/dashboard_analyzer_console.png)
21+
## Testing the Analyzer
22+
<VideoPlayer src={applyAnalyzer} />
23+
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'`;
25+
2026

21-
Once we have executed this query, we can go back to the Analyzer panel and see that it has been successfully analyzed by the **nemtfenosk** node.
27+
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.
2228

23-
![Dashboard Analyzer Query](@docs-website-assets/introduction/dashboard_analyzer_query.png)
2429

2530
By selecting **Details** and **Plan**, we can get more in-depth information about the execution of this query over time. However, what we're most interested in is the intelligent recommendation, which can be found by selecting **Suggest**. In the Indexes field, we can find the optimal index to apply to our database, which will speed up all queries on the Track table filtered by the Composer column.
2631

27-
![Dashboard Analyzer Suggestion](@docs-website-assets/introduction/dashboard_analyzer_suggest.png)
2832

2933
To apply the recommended index(es), simply select **Apply** and they will be automatically written and distributed in the `Chinook.sqlite` database.

sqlite-cloud/platform/edge-functions.mdx

Lines changed: 24 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ slug: edge-functions
88
import VideoPlayer from '@commons-components/Video/VideoPlayer.astro';
99
import edgeFunctions from '@docs-website-assets/introduction/video/dashboard_edge_functions.mp4';
1010

11+
import Callout from "@commons-components/Information/Callout.astro";
12+
1113
Edge functions let you define custom logic to run on the same nodes as your database files for ultra-fast performance.
1214

1315
You can write edge functions directly in the SQLite Cloud dashboard using JavaScript, TypeScript, or SQL. Importing modules is not currently supported.
@@ -18,68 +20,41 @@ Turning on linearizable reads ensures strong consistency, but may introduce some
1820

1921
## Getting Started
2022

21-
This guide explains how to create, deploy, and test Edge Functions in the SQLite Cloud UI.
22-
23-
<VideoPlayer src={edgeFunctions} />
24-
23+
Use the **Edge Functions panel** to effortlessly create, deploy, and test Edge Functions directly in the SQLite Cloud dashboard.
24+
The editor allows you to choose the language of your function — **JavaScript**, **TypeScript**, or **SQL** — and connect it to the database of your choice.
2525

26+
Once deployed, the function can be tested immediately in the dashboard or invoked externally through its Function URL.
2627

27-
1. Open the Edge Functions Section
28-
- From the left-hand sidebar, click the **Edge Functions** icon.
29-
- You will see the list of your functions on the left and the code editor on the right.
28+
<VideoPlayer src={edgeFunctions} />
3029

31-
2. Create a New Function
32-
- Click the **+** button next to *Filter functions...*.
33-
- Choose the function type: **SQL**, **JavaScript**, or **TypeScript**.
34-
- A new function (e.g., `function-1`) will appear in the list.
30+
#### Note:
31+
Functions should return a JSON-serializable object with a data field:
32+
```js
33+
return {
34+
data: {
35+
// your return object
36+
}
37+
}
38+
```
3539

36-
3. Write Your Function Code
37-
- Use the editor to implement your logic.
38-
- You can include request parameters, execute SQL queries, and return custom objects.
3940

40-
4. Select the Target Database
41-
- At the bottom of the editor, choose the database (e.g., `chinook.sqlite`).
42-
- You can search and switch databases if needed.
4341

44-
5. Deploy the Function
45-
- Before testing, you must **Deploy** the function.
46-
- Click the **Deploy** button in the bottom-right corner.
47-
- The function is now active and ready to be tested.
42+
<Callout type="note">
43+
Enabling **linearizable reads** guarantees strong consistency but may introduce additional latency.
44+
For most cases, we recommend keeping it disabled to benefit from lower response times.
45+
</Callout>
4846

49-
6. Test the Function
50-
- After deployment, click **Test**.
51-
- A panel will open on the right where you can configure:
52-
- **User** → choose a user with access to the selected database.
53-
- **API Key** → select the appropriate key.
54-
- **Request Body** → provide JSON input (e.g., `{ "filter": "a" }`).
55-
- **Query Parameters** → add parameters (e.g., `limit = 10`).
56-
- Click **Send Request** to execute the test.
5747

58-
7. Review the Response
59-
- The response will be shown at the bottom of the test panel.
60-
- It includes your custom message, the SQL results, and the request object.
48+
### Function Details
6149

62-
8. Enable Linearizable Reads (Optional)
63-
- If your database is frequently modified and you want strong consistency,
64-
toggle **Linearizable** at the bottom before testing or deploying.
50+
In the **Details** tab you will find key information about your function, including:
6551

66-
9. View the Function Details
67-
- Switch to the **Details** tab to check deployment information.
68-
- You can see:
69-
- The **last deployed date and time**.
70-
- The **Function URL**, which you can copy and use to call the function from external applications
52+
- The **last deployment date and time**
53+
- The **Function URL**, which you can use to call the function from external applications
7154

55+
![Edge Function Details](@docs-website-assets/introduction/dahsboard-edge-function-details.png)
7256

7357

74-
#### Note:
75-
Functions should return a JSON-serializable object with a data field:
76-
```js
77-
return {
78-
data: {
79-
// your return object
80-
}
81-
}
82-
```
8358

8459
### Authorization
8560
Edge functions that access your SQLite databases must be authorized via API key.

sqlite-cloud/platform/offsync.mdx

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ status: publish
66
slug: offsync
77
---
88

9+
import VideoPlayer from '@commons-components/Video/VideoPlayer.astro';
10+
import enableSync from '@docs-website-assets/introduction/video/dashboard_sqlite_sync_enabling.mp4';
11+
import connectionUrlSync from '@docs-website-assets/introduction/video/dashboard_sync_connection_url.mp4';
12+
import devicesSync from '@docs-website-assets/introduction/video/dashboard_sync_devices.mp4';
13+
14+
15+
916
import Callout from "@commons-components/Information/Callout.astro";
1017

1118
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.
@@ -24,16 +31,28 @@ When combined with [Row-Level Security (RLS)](/docs/rls), OffSync allows you to
2431

2532
## Configuring OffSync
2633

27-
You can enable and manage OffSync for your databases directly from the SQLite Cloud dashboard.
34+
You can enable and manage OffSync for your databases directly from the SQLite Cloud dashboard.
35+
Below are the main steps:
36+
37+
### 1. Enable Tables for Synchronization
38+
From the **Sync Tables** tab, select which tables in your database you want to keep synchronized.
39+
Once enabled, all changes to those tables will automatically sync with connected devices.
40+
41+
<VideoPlayer src={enableSync} />
42+
43+
44+
### 2. Get the Connection String
45+
In the **Configuration** tab, copy the connection string.
46+
Use this in your application to initialize OffSync and connect your local SQLite database with SQLite Cloud.
2847

29-
1. **Navigate to the Databases Page**: From the main dashboard, go to the "Databases" page.
30-
2. **Select the Offsync Column**: In the list of your databases, click on the button in the "Offsync" column for the desired database.
48+
<VideoPlayer src={connectionUrlSync} />
3149

32-
![Dashboard Databases Page](@docs-website-assets/introduction/offsync-1.png)
3350

34-
3. **Enable Tables for Synchronization**: On the Offsync settings page, you will see a list of all tables in your database. Toggle the switch next to each table you want to enable for synchronization.
51+
### 3. Manage Connected Devices
52+
In the **Devices** tab, you can view all devices currently connected to your database.
53+
Here you can check their sync status and remove devices if needed.
3554

36-
![Dashboard Offsync Settings Page](@docs-website-assets/introduction/offsync-2.png)
55+
<VideoPlayer src={devicesSync} />
3756

3857
<Callout type="note" title="Matching Schemas and Tables">
3958
For OffSync to work correctly, the list of tables configured for synchronization—and their corresponding schemas—must be identical in both your local SQLite database and your SQLite Cloud database.

sqlite-cloud/platform/rls.mdx

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ status: publish
66
slug: rls
77
---
88

9+
import VideoPlayer from '@commons-components/Video/VideoPlayer.astro';
10+
import rlsEnable from '@docs-website-assets/introduction/video/dashboard_rls_enable.mp4';
11+
import rlsTest from '@docs-website-assets/introduction/video/dashboard_rls_test.mp4';
12+
13+
14+
915
import Callout from "@commons-components/Information/Callout.astro";
1016

1117
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.
@@ -38,14 +44,12 @@ Otherwise, they will be blocked from accessing any rows.
3844

3945
You can configure RLS policies for your databases through the SQLite Cloud dashboard.
4046

47+
<VideoPlayer src={rlsEnable} />
48+
4149
1. **Navigate to the Databases Page**: From the main dashboard, go to the "Databases" page.
4250
2. **Select the RLS Column**: In the list of your databases, click on the button in the "RLS" column for the desired database.
43-
44-
![Dashboard Databases Page](@docs-website-assets/introduction/rls-1.png)
45-
4651
3. **Configure RLS Settings**: On the RLS settings page, you can define the policies for each table.
4752

48-
![Dashboard RLS Settings Page](@docs-website-assets/introduction/rls-2.png)
4953

5054
For each table, you can specify the following RLS policies:
5155

@@ -58,6 +62,31 @@ You can configure RLS policies for your databases through the SQLite Cloud dashb
5862
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.
5963
</Callout>
6064

65+
## Testing RLS
66+
<VideoPlayer src={rlsTest} />
67+
68+
To verify that your Row-Level Security (RLS) policies work as expected, you can use the **Test RLS** feature in the dashboard:
69+
70+
1. **Open the Test Panel**
71+
On the RLS policies page, click **Test** to open the dedicated testing panel.
72+
73+
2. **Generate an Access Token**
74+
- Go to the **Weblite page** and use the `POST /v2/tokens` endpoint.
75+
- Provide a request body with a `userId`, a `name`, and any attributes required by your RLS policies (for example: `role`, `enabled`, etc.).
76+
- Execute the request and copy the `token` value from the response.
77+
78+
3. **Authenticate in the Test Panel**
79+
- Paste the generated token into the **Enter Access Token** field and click **Authorize**.
80+
- The dashboard will now simulate queries to the database as if they were executed by the user identified in the token.
81+
82+
4. **View Filtered Data**
83+
- Once authenticated, you can navigate through the database tables directly from the test panel.
84+
- Only the rows allowed by your RLS rules will be displayed (for example, activities tied to the `user_id` in the token or accessible with the `coach` role).
85+
86+
5. **Compare with Full Data**
87+
- By switching back to **Database Studio**, you can see all rows in the table without RLS filters.
88+
- This allows you to compare the filtered view (via token) with the complete dataset and confirm that your policies are correctly enforced.
89+
6190
### User Information Functions
6291

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

sqlite-cloud/platform/webhooks.mdx

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ For example, you can configure SQLite Cloud to notify a [webhook.site](https://w
2121
<VideoPlayer src={webhooksUrl} />
2222

2323

24+
2425
## Change Data Capture
2526

2627
Change Data Webhooks let you send structured HTTP requests to any external service whenever a row in a specific database and/or table is modified. These webhooks include:
@@ -32,20 +33,73 @@ Change Data Webhooks let you send structured HTTP requests to any external servi
3233

3334
This enables seamless integration with logging systems, monitoring dashboards, or external APIs that react to database activity.
3435

36+
37+
### Payload Fields
38+
39+
```json
40+
{
41+
"type": "insert",
42+
"database": "chinook.sqlite",
43+
"table": "albums",
44+
"column": [
45+
"AlbumId"
46+
],
47+
"data": [
48+
349
49+
],
50+
"webhook": {
51+
"id": 1,
52+
"action": "https://webhook.site/70792a3c-2a18-4a48-9ded-df1c90e758ce",
53+
"options": {
54+
"type": "url"
55+
}
56+
}
57+
}
58+
```
59+
60+
* **type** – The operation type (`insert`, `update`, or `delete`).
61+
* **database** – The name of the database where the change occurred.
62+
* **table** – The table affected by the operation.
63+
* **column** – An array listing the column(s) involved in the operation.
64+
* **data** – The values corresponding to the affected row(s).
65+
* **webhook** – Metadata about the webhook itself, including its unique `id`, target `action` (URL or Edge Function), and configuration `options`.
66+
67+
## Security
68+
3569
Upon creation, each webhook is assigned a **secret key** used to verify the authenticity of incoming requests.
3670

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

39-
You can also manage and review all active webhooks from your project dashboard.
40-
41-
![Dashboard Projects](@docs-website-assets/introduction/dashboard_webhook_list.png)
4273

4374
## Trigger Edge Functions
4475

4576
Webhooks in SQLite Cloud aren't limited to data capture—they can also **trigger Edge Functions**:
4677

4778
* Via HTTP or WebSocket
4879
* In response to database write events
80+
4981
<VideoPlayer src={webhooksEdgeFunction} />
5082

83+
Within an Edge Function, the webhook payload containing the **Change Data Capture** information is directly accessible through the `request.data` variable, which is available by default in all Edge Functions.
84+
85+
```js
86+
// Get secret from database
87+
const slackWebhookEndpoint = await connection.sql`GET ENV slack_webhook_endpoint`;
88+
89+
// Get record sent in body via webhook
90+
const content = request.data;
91+
92+
// Define helpers to assign and notify
93+
const notifyRep = async ( ) => {
94+
await fetch(slackWebhookEndpoint, { body: JSON.stringify({ text: "Discover the Latest Album Releases" + JSON.stringify(request.data)}), method: 'POST', 'Content-type': 'application/json' });
95+
}
96+
97+
// Call async functions
98+
await notifyRep();
99+
100+
return {
101+
data: 'OK'
102+
}
103+
```
104+
51105
This allows developers to build distributed, event-driven applications that react immediately to changes at the edge.

0 commit comments

Comments
 (0)