sqlite-actor 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -43
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,37 +1,27 @@
|
|
|
1
|
-
#
|
|
1
|
+
# sqlite-actor 🎭
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> [!IMPORTANT]
|
|
4
|
+
> `sqlite-actor` is pre-v1, so expect breaking changes!
|
|
5
|
+
|
|
6
|
+
A WebAssembly (WASM) build of SQLite designed specifically to run in single-threaded Actor environments (such as Cloudflare Durable Objects).
|
|
7
|
+
|
|
8
|
+
Since modern Actor platforms increasingly provide robust native SQLite storage (instead of purely key-value), `sqlite-actor` gives you access to a custom WASM SQLite build that you can run *on top of* your actor's standard storage.
|
|
9
|
+
|
|
10
|
+
**Why use this instead of the platform's native SQLite?**
|
|
11
|
+
To get access to SQLite extensions that aren't natively supported by your platform!
|
|
12
|
+
|
|
13
|
+
## Supported Extensions
|
|
14
|
+
|
|
15
|
+
Currently, `sqlite-actor` bundles the following extensions directly into its WASM build:
|
|
16
|
+
|
|
17
|
+
- **[sqlite-vec](https://github.com/asg017/sqlite-vec)**: A vector search extension that enables RAG and semantic search directly isolated inside your Actors.
|
|
18
|
+
|
|
19
|
+
*(Note: We plan to support more extensions in the future based on user requests. Please open a GitHub issue if you need another extension.)*
|
|
4
20
|
|
|
5
21
|
## Features
|
|
6
|
-
- **
|
|
7
|
-
- **
|
|
8
|
-
- **
|
|
9
|
-
- **Reliable**: Professional VFS implementation with multi-page support, VACUUM, and ACID compliance (through underlying KV).
|
|
10
|
-
|
|
11
|
-
## Architecture
|
|
12
|
-
|
|
13
|
-
Actordb bridges the gap between the SQLite engine and the Actor's KV storage using a custom VFS (Virtual File System) implementation.
|
|
14
|
-
|
|
15
|
-
```mermaid
|
|
16
|
-
graph TD
|
|
17
|
-
subgraph "Application"
|
|
18
|
-
App[Your Code] --> SDK[SqliteActor SDK]
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
subgraph "Actordb Core (WASM)"
|
|
22
|
-
SDK --> WASM[WASM DB]
|
|
23
|
-
WASM --> VFS[C VFS Bridge]
|
|
24
|
-
VFS --> KV[JS KV Interface]
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
subgraph "Actor Platform (e.g. Cloudflare)"
|
|
28
|
-
KV --> Storage[Durable Storage]
|
|
29
|
-
Storage --> Replication[Global Replication]
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
style KV fill:#f96,stroke:#333,stroke-width:2px
|
|
33
|
-
note[Actor platform provides the KV Interface]
|
|
34
|
-
```
|
|
22
|
+
- **Zero-Config**: The WASM binary is heavily optimized and compiled directly into the JavaScript bundle. No `.wasm` file fetching is required—just `import` and run.
|
|
23
|
+
- **Synchronous API**: Designed for the single-threaded nature of Actors, the SDK is completely synchronous after the initial load.
|
|
24
|
+
- **VFS Bridge**: It uses a memory-first Virtual File System (VFS) to back the database to the actor's provided key-value storage.
|
|
35
25
|
|
|
36
26
|
## Getting Started
|
|
37
27
|
|
|
@@ -49,13 +39,13 @@ export class MyVectorActor {
|
|
|
49
39
|
// Initialize DB with the Durable Object storage (kv)
|
|
50
40
|
const db = await SqliteActor.create(this.state.storage);
|
|
51
41
|
|
|
52
|
-
// Create a vector table
|
|
42
|
+
// Create a vector table powered by sqlite-vec
|
|
53
43
|
db.execute("CREATE VIRTUAL TABLE vec_items USING vec0(embedding float[3]);");
|
|
54
44
|
|
|
55
|
-
// Insert a vector
|
|
45
|
+
// Insert a vector embedding
|
|
56
46
|
db.execute("INSERT INTO vec_items(rowid, embedding) VALUES (1, '[1.1, 2.2, 3.3]');");
|
|
57
47
|
|
|
58
|
-
// Perform vector search
|
|
48
|
+
// Perform a vector search
|
|
59
49
|
const results = db.query("SELECT rowid, distance FROM vec_items WHERE embedding MATCH '[1.0, 2.0, 3.0]' AND k = 1;");
|
|
60
50
|
|
|
61
51
|
return new Response(JSON.stringify(results));
|
|
@@ -63,22 +53,18 @@ export class MyVectorActor {
|
|
|
63
53
|
}
|
|
64
54
|
```
|
|
65
55
|
|
|
66
|
-
## Development
|
|
56
|
+
## Development setup (Building from Source)
|
|
67
57
|
|
|
68
|
-
|
|
69
|
-
Ensure you have [Emscripten](https://emscripten.org/docs/getting_started/downloads.html) installed and in your path. Then, download the SQLite and `sqlite-vec` sources:
|
|
58
|
+
Ensure you have [Emscripten](https://emscripten.org/docs/getting_started/downloads.html) installed locally.
|
|
70
59
|
|
|
71
60
|
```bash
|
|
61
|
+
# Fetch upstream SQLite and sqlite-vec C sources
|
|
72
62
|
npm run setup
|
|
73
|
-
```
|
|
74
63
|
|
|
75
|
-
|
|
76
|
-
```bash
|
|
64
|
+
# Compile the WASM and build the TypeScript SDK
|
|
77
65
|
npm run build
|
|
78
|
-
```
|
|
79
66
|
|
|
80
|
-
|
|
81
|
-
```bash
|
|
67
|
+
# Run the test suite
|
|
82
68
|
npm test
|
|
83
69
|
```
|
|
84
70
|
|