Skip to content

Commit b15c8fb

Browse files
committed
update fundamentals and edge functions
1 parent a59ed86 commit b15c8fb

4 files changed

Lines changed: 22 additions & 27 deletions

File tree

sqlite-cloud/connect-cluster.mdx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ slug: connect-cluster
88

99
SQLite databases in SQLite Cloud are distributed across a cluster of nodes. Each cluster comes with a multi-region load balancer that routes traffic to the nearest appropriate node.
1010

11-
For this reason, we strongly recommend connecting to your cluster via your project connection string. To retrieve your project connection string, navigate to the **Nodes** page and click on any node.
12-
{/* ![Project connection string modal](@docs-website-assets/connect-cluster-1.png) */}
13-
14-
Copy the connection string and use it with a client library to connect to your cluster.
11+
Click "Connect" in the bottom left-hand corner of your dashboard to get your connection string to use with a SQLite Cloud client library.
1512

1613
## Connecting with JavaScript
1714
Here's an example of how you can connect to your cluster using the `@sqlitecloud/drivers` JavaScript client library:

sqlite-cloud/create-database.mdx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ status: publish
66
slug: create-database
77
---
88

9-
SQLite Cloud allows you to import existing SQLite Databases, or create a new database in SQLite Cloud by importing an existing SQLite database, or using the SQLite Cloud UI, API, or client libraries.
9+
You can import an existing SQLite databases, or create new databases using the SQLite Cloud UI, API, or client libraries.
1010

1111
## Importing an existing SQLite database
1212
SQLite Cloud allows you to import existing SQLite databases into the platform.
@@ -27,7 +27,7 @@ To create a new database from the SQLite Cloud UI, navigate to the Databases tab
2727
The default encoding is set to UTF-8, and the default page size is 4096KB.
2828

2929
### From the API
30-
To create a new database or upload an existing database via [Weblite](#), our REST API, you can make a request with the following parameters:
30+
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:
3131
```bash
3232
curl -X 'POST' \
3333
'https://<your-project-id>.sqlite.cloud:8090/v2/weblite/<database-name>.sqlite' \
@@ -37,17 +37,30 @@ curl -X 'POST' \
3737
```
3838

3939
### From client libraries
40-
To create a new database from a client library, use the CREATE DATABASE command.
40+
To create a new database from a client library, connect to your cluster using a connection string without a specified database.
41+
42+
Then, use the CREATE DATABASE command to create a new database.
43+
44+
To start using the database within the connection, you can use the `USE DATABASE` command.
4145

4246
```javascript
4347
import { Database } from '@sqlitecloud/drivers';
44-
48+
// note that no database name is specified in the connection string path
4549
const db = new Database('sqlitecloud://<your-project-id>.sqlite.cloud:<your-host-port>?apikey=<your-api-key>')
4650

4751
const createDatabase = async () => await db.sql`CREATE DATABASE <database-name>;`;
4852

4953
createDatabase().then((res) => console.log(res));
5054

5155
// "OK"
56+
57+
db.exec('USE DATABASE <database-name>;')
58+
59+
// now you can use the database
60+
const fetchAlbums = async () => await db.exec`SELECT * FROM albums;`;
61+
62+
fetchAlbums().then((albums) => console.log(albums));
63+
64+
// [{ Title: 'For Those About To Rock We Salute You', ... }, ...]
5265
```
5366

sqlite-cloud/platform/edge-functions.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ status: publish
66
slug: edge-functions
77
---
88

9-
Edge Functions are server-side functions that run directly within your database environment. Edge functions in SQLite Cloud ensure maximum performance and minimal latency by running functions on the same server as your database.
9+
Edge functions let you define custom logic to run on the same nodes as your database files for ultra-fast performance.
1010

1111
You can write edge functions directly in the SQLite Cloud dashboard using JavaScript, TypeScript, or SQL. Importing modules is not currently supported.
1212

sqlite-cloud/write-data.mdx

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,7 @@ status: publish
66
slug: write-data
77
---
88

9-
After you've created a database in SQLite Cloud, you can start writing data to it. You can write data to your cluster using the SQLite Cloud UI, API, or client libraries.
10-
11-
## Upload an existing SQLite Database
12-
You can upload an existing SQLite database to your cluster using the SQLite Cloud UI or the Weblite API.
13-
14-
To upload a local SQLite database via weblite, make a POST request to the `/v2/weblite/<database-name>.sqlite` endpoint.
15-
16-
```bash
17-
curl -X 'POST' \
18-
'https://<your-project-id>.sqlite.cloud:8090/v2/weblite/<database-name>.sqlite' \
19-
-H 'accept: application/json' \
20-
-H 'Authorization: Bearer sqlitecloud://<your-project-id>.sqlite.cloud:8860?apikey=<your-api-key' \
21-
-d ''
22-
```
23-
24-
To upload a local SQLite database via the SQLite Cloud UI, navigate to the Database tab in the left-hand navigation. Click the "Upload Database" button and select your local SQLite database.
9+
After you've created a database in SQLite Cloud, you can start writing data to it.
2510

2611
## Writing data with the SQLite Cloud UI
2712
Navigate to the console tab in the left-hand navigation. From here, you can run SQL commands against your cluster. Use the optional dropdown menus to select a database and table.
@@ -39,7 +24,7 @@ INSERT INTO sports_cars (sc_name, sc_year, image) VALUES ('Ferrari', 2021, 'http
3924
```
4025

4126
## Writing data with the Weblite API
42-
You can use the API to run SQL commands against your cluster.
27+
You can use the [Weblite API](/docs/weblite) to run SQL commands against your cluster. Here is an example cURL request:
4328

4429
```bash
4530
curl -X 'POST' \
@@ -57,7 +42,7 @@ import { Database } from '@sqlitecloud/drivers';
5742

5843
const db = new Database('sqlitecloud://<your-project-id>.sqlite.cloud:<your-host-port>?apikey=<your-api-key>')
5944
db.exec('USE DATABASE mydatabase.sqlite;')
60-
db.exec('CREATE TABLE sports_cars (sc_id INTEGER PRIMARY KEY, sc_name TEXT NOT NULL, sc_year INTEGER NOT NULL, image BLOB);')
45+
db.exec('CREATE TABLE sports_cars (sc_id INTEGER PRIMARY KEY, sc_name TEXT NOT NULL, sc_year INTEGER NOT NULL, image_url text);')
6146
db.commit()
6247
const insertData = async () => await db.sql`INSERT INTO sports_cars (sc_name, sc_year, image) VALUES ('Ferrari', 2021, 'https://example.com/ferrari.jpg');`;
6348

0 commit comments

Comments
 (0)