Package Exports
- @sqlite-actor/core
- @sqlite-actor/core/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@sqlite-actor/core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@sqlite-actor/core
The foundation for Actor-DB. This package provides the core SQLite Virtual File System (VFS) and the base SqliteActor class for building memory-efficient, actor-based databases.
Features
- Lazy-Loading VFS: SQLite pages are fetched on-demand from a Key-Value store. This ensures a constant memory footprint (O(1)) regardless of database size, enabling multi-GB databases in restricted environments (e.g., Cloudflare Workers).
- Binary-First Query Engine: High-performance
exec()method that supportsTypedArraybindings and returns a lazySqliteCursor, bypassing expensive JSON serialization. - Synchronous Storage: Explicitly designed for actor environments where synchronous (non-Promise) storage access is available (like Cloudflare Durable Objects).
Installation
npm install @sqlite-actor/coreUsage
@sqlite-actor/core provides the base class. You'll typically use a specialized package like @sqlite-actor/sqlite-vec, but you can use core directly with your own SQLite WASM build:
import { SqliteActor } from "@sqlite-actor/core";
import initSqlite3 from "./your-sqlite-glue.js";
const db = new SqliteActor(this.ctx.storage);
await db.init(initSqlite3, { wasmBinary: yourBinary });
// Create schema
db.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, metadata BLOB);");
// High-performance inserts with binary support
const metadata = new Uint8Array([0x01, 0x02, 0x03]);
db.exec("INSERT INTO users (name, metadata) VALUES (?, ?)", ["Alice", metadata]);
// Memory-efficient retrieval via Cursor API
const cursor = db.exec("SELECT * FROM users");
for (const row of cursor) {
console.log(`User: ${row.name}`);
}
// Convenience methods
const allUsers = db.exec("SELECT * FROM users").toArray();
const firstUser = db.exec("SELECT * FROM users LIMIT 1").one();License
MIT