Skip to content

Commit a9231e2

Browse files
committed
♻️ refactor: rename VFS type 'memdb' to 'memory'
1 parent 01bcba0 commit a9231e2

5 files changed

Lines changed: 144 additions & 130 deletions

File tree

PROJECT_SUMMARY.md

Lines changed: 90 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
## Overview
44

5-
**sqlite-wasm-easy** is a zero-configuration wrapper around `@sqlite.org/sqlite-wasm` that simplifies SQLite database usage in the browser.
5+
**sqlite-wasm-easy** is a zero-configuration wrapper around `@sqlite.org/sqlite-wasm` that
6+
simplifies SQLite database usage in the browser.
67

78
## ✅ What We Built
89

910
### Core Features
11+
1012
1. **Zero Configuration** - Works out of the box with sensible defaults
1113
2. **Fully Configurable** - VFS type, PRAGMA settings, logging options
1214
3. **TypeScript First** - Complete type safety and IntelliSense
@@ -53,32 +55,32 @@ All aspects are configurable with sensible defaults:
5355

5456
```typescript
5557
interface SQLiteWASMConfig {
56-
filename: string;
57-
vfs?: {
58-
type?: 'opfs-sahpool' | 'opfs' | 'memdb';
59-
poolConfig?: {
60-
initialCapacity?: number; // Default: 3
61-
clearOnInit?: boolean; // Default: false
62-
name?: string; // Default: 'sqlite-wasm-pool'
63-
};
64-
};
65-
pragma?: {
66-
journal_mode?: JournalMode; // Default: 'WAL'
67-
synchronous?: SynchronousMode; // Default: 'NORMAL'
68-
temp_store?: TempStoreMode; // Default: 'MEMORY'
69-
cache_size?: number;
70-
page_size?: number;
71-
foreign_keys?: 'ON' | 'OFF';
72-
[key: string]: any; // Any custom PRAGMA
73-
};
74-
worker?: {
75-
path?: string; // Custom worker path
76-
};
77-
logging?: {
78-
filterSqlTrace?: boolean; // Default: true
79-
print?: (msg: string) => void;
80-
printErr?: (msg: string) => void;
81-
};
58+
filename: string;
59+
vfs?: {
60+
type?: 'opfs-sahpool' | 'opfs' | 'memory';
61+
poolConfig?: {
62+
initialCapacity?: number; // Default: 3
63+
clearOnInit?: boolean; // Default: false
64+
name?: string; // Default: 'sqlite-wasm-pool'
65+
};
66+
};
67+
pragma?: {
68+
journal_mode?: JournalMode; // Default: 'WAL'
69+
synchronous?: SynchronousMode; // Default: 'NORMAL'
70+
temp_store?: TempStoreMode; // Default: 'MEMORY'
71+
cache_size?: number;
72+
page_size?: number;
73+
foreign_keys?: 'ON' | 'OFF';
74+
[key: string]: any; // Any custom PRAGMA
75+
};
76+
worker?: {
77+
path?: string; // Custom worker path
78+
};
79+
logging?: {
80+
filterSqlTrace?: boolean; // Default: true
81+
print?: (msg: string) => void;
82+
printErr?: (msg: string) => void;
83+
};
8284
}
8385
```
8486

@@ -88,26 +90,26 @@ Only high-level methods (no CRUD):
8890

8991
```typescript
9092
class SQLiteWASM<Schema = any> {
91-
ready(): Promise<void>
92-
exec(sql: string, params?: any[]): Promise<void>
93-
query<T>(sql: string, params?: any[]): Promise<T[]>
94-
run(sql: string, params?: any[]): Promise<RunResult>
95-
transaction(callback: (tx: Transaction) => Promise<void>): Promise<void>
96-
table<K extends keyof Schema>(name: K): TypedTable<Schema[K]>
97-
export(): Promise<Uint8Array>
98-
import(filename: string, data: Uint8Array): Promise<void>
99-
close(): Promise<void>
100-
delete(): Promise<void>
93+
ready(): Promise<void>;
94+
exec(sql: string, params?: any[]): Promise<void>;
95+
query<T>(sql: string, params?: any[]): Promise<T[]>;
96+
run(sql: string, params?: any[]): Promise<RunResult>;
97+
transaction(callback: (tx: Transaction) => Promise<void>): Promise<void>;
98+
table<K extends keyof Schema>(name: K): TypedTable<Schema[K]>;
99+
export(): Promise<Uint8Array>;
100+
import(filename: string, data: Uint8Array): Promise<void>;
101+
close(): Promise<void>;
102+
delete(): Promise<void>;
101103
}
102104
```
103105

104106
### TypedTable (Type Hints Only)
105107

106108
```typescript
107109
interface TypedTable<T> {
108-
query<R = T>(sql: string, params?: any[]): Promise<R[]>
109-
exec(sql: string, params?: any[]): Promise<void>
110-
run(sql: string, params?: any[]): Promise<RunResult>
110+
query<R = T>(sql: string, params?: any[]): Promise<R[]>;
111+
exec(sql: string, params?: any[]): Promise<void>;
112+
run(sql: string, params?: any[]): Promise<RunResult>;
111113
}
112114
```
113115

@@ -131,32 +133,32 @@ const users = await db.query('SELECT * FROM users');
131133

132134
```typescript
133135
const db = new SQLiteWASM({
134-
filename: 'myapp.db',
135-
vfs: {
136-
type: 'opfs-sahpool',
137-
poolConfig: {
138-
initialCapacity: 5,
139-
clearOnInit: false,
140-
name: 'custom-pool'
141-
}
142-
},
143-
pragma: {
144-
journal_mode: 'WAL',
145-
synchronous: 'FULL',
146-
foreign_keys: 'ON'
147-
},
148-
logging: {
149-
filterSqlTrace: true
150-
}
136+
filename: 'myapp.db',
137+
vfs: {
138+
type: 'opfs-sahpool',
139+
poolConfig: {
140+
initialCapacity: 5,
141+
clearOnInit: false,
142+
name: 'custom-pool',
143+
},
144+
},
145+
pragma: {
146+
journal_mode: 'WAL',
147+
synchronous: 'FULL',
148+
foreign_keys: 'ON',
149+
},
150+
logging: {
151+
filterSqlTrace: true,
152+
},
151153
});
152154
```
153155

154156
### 3. TypeScript Schema
155157

156158
```typescript
157159
interface Schema {
158-
users: { id: number; name: string; email: string };
159-
posts: { id: number; userId: number; title: string };
160+
users: { id: number; name: string; email: string };
161+
posts: { id: number; userId: number; title: string };
160162
}
161163

162164
const db = new SQLiteWASM<Schema>({ filename: 'app.db' });
@@ -171,54 +173,57 @@ const users = await usersTable.query('SELECT * FROM users');
171173

172174
```typescript
173175
await db.transaction(async (tx) => {
174-
await tx.exec('INSERT INTO users (name) VALUES (?)', ['Charlie']);
175-
await tx.exec('UPDATE users SET active = 1 WHERE id = ?', [1]);
176+
await tx.exec('INSERT INTO users (name) VALUES (?)', ['Charlie']);
177+
await tx.exec('UPDATE users SET active = 1 WHERE id = ?', [1]);
176178
});
177179
```
178180

179181
## Key Differences from Your Current Implementation
180182

181-
| Aspect | Current (Supersorted) | sqlite-wasm-easy |
182-
|--------|----------------------|------------------|
183-
| **Scope** | App-specific | General-purpose package |
184-
| **Configuration** | Hardcoded values | Fully configurable |
185-
| **Table API** | Full ORM-like (insert, update, delete, etc.) | Type hints only (query, exec, run) |
186-
| **PRAGMA** | Hardcoded (MEMORY, NORMAL) | User configurable |
187-
| **VFS** | Hardcoded opfs-sahpool | User can choose (opfs-sahpool, opfs, memdb) |
188-
| **Pool Config** | Fixed (initialCapacity: 3) | Configurable |
189-
| **Console Filtering** | Always on | Optional (configurable) |
183+
| Aspect | Current (Supersorted) | sqlite-wasm-easy |
184+
| --------------------- | -------------------------------------------- | -------------------------------------------- |
185+
| **Scope** | App-specific | General-purpose package |
186+
| **Configuration** | Hardcoded values | Fully configurable |
187+
| **Table API** | Full ORM-like (insert, update, delete, etc.) | Type hints only (query, exec, run) |
188+
| **PRAGMA** | Hardcoded (MEMORY, NORMAL) | User configurable |
189+
| **VFS** | Hardcoded opfs-sahpool | User can choose (opfs-sahpool, opfs, memory) |
190+
| **Pool Config** | Fixed (initialCapacity: 3) | Configurable |
191+
| **Console Filtering** | Always on | Optional (configurable) |
190192

191193
## What's Configurable (vs Hardcoded Before)
192194

193-
**VFS Method** - User chooses: opfs-sahpool, opfs, or memdb
194-
**Pool Settings** - initialCapacity, clearOnInit, name
195+
**VFS Method** - User chooses: opfs-sahpool, opfs, or memory ✅ **Pool Settings** -
196+
initialCapacity, clearOnInit, name
195197
**PRAGMA Settings** - journal_mode, synchronous, temp_store, cache_size, etc.
196198
**Logging** - filterSqlTrace, custom print/printErr functions
197-
**Worker Path** - Custom worker location
199+
**Worker Path** - Custom worker location
198200

199201
## Build & Distribution
200202

201203
### Build Output
204+
202205
- Main bundle: `dist/index.js` (14.5 KB, gzipped: 5.5 KB)
203206
- Worker bundle: `dist/worker/sqliteWorker.js` (5 KB, gzipped: 1.6 KB)
204207
- TypeScript declarations: `dist/index.d.ts`
205208

206209
### NPM Package Structure
210+
207211
```json
208212
{
209-
"name": "sqlite-wasm-easy",
210-
"main": "./dist/index.js",
211-
"types": "./dist/index.d.ts",
212-
"exports": {
213-
".": "./dist/index.js",
214-
"./worker": "./dist/worker/sqliteWorker.js"
215-
}
213+
"name": "sqlite-wasm-easy",
214+
"main": "./dist/index.js",
215+
"types": "./dist/index.d.ts",
216+
"exports": {
217+
".": "./dist/index.js",
218+
"./worker": "./dist/worker/sqliteWorker.js"
219+
}
216220
}
217221
```
218222

219223
## Next Steps
220224

221225
### For Development
226+
222227
```bash
223228
cd sqlite-wasm-easy
224229
npm install
@@ -227,10 +232,12 @@ npm run typecheck # Type checking only
227232
```
228233

229234
### For Testing
235+
230236
1. Open `examples/basic.html` in a browser (via dev server)
231237
2. Open `examples/typed-schema.html` for TypeScript examples
232238

233239
### For Publishing
240+
234241
```bash
235242
# Test locally first
236243
npm pack
@@ -253,14 +260,16 @@ npm publish
253260

254261
✅ Chrome/Edge 102+
255262
✅ Firefox (with OPFS support)
256-
⚠️ Safari (experimental OPFS support)
263+
⚠️ Safari (experimental OPFS support)
257264

258265
## Dependencies
259266

260267
**Peer Dependencies:**
268+
261269
- `@sqlite.org/sqlite-wasm`: ^3.49.0
262270

263271
**Dev Dependencies:**
272+
264273
- `typescript`: ^5.7.3
265274
- `vite`: ^6.1.0
266275

0 commit comments

Comments
 (0)