create
Essential
The create function opens a TinyJoin database in a dedicated Worker.
create(): Promise<Client>| returns | Promise<Client> |
|---|
Calling it with no argument creates an ephemeral memory database. Pass a stable opfs://name to persist the database in browser storage.
Example
import {create} from 'tinyjoin';
const db = await create('opfs://my-app');
await db.exec(`
CREATE TABLE IF NOT EXISTS tasks (
id INTEGER PRIMARY KEY,
title TEXT NOT NULL
)
`);
const {rows} = await db.query('SELECT * FROM tasks ORDER BY id');
await db.close();
Since
v0.0.5
create(options: ClientOptions): Promise<Client>| Type | Description | |
|---|---|---|
options | ClientOptions | |
| returns | Promise<Client> |
create(
dataDir: undefined | string,
options?: ClientOptions,
): Promise<Client>| Type | Description | |
|---|---|---|
dataDir | undefined | string | |
options? | ClientOptions | |
| returns | Promise<Client> |