@@ -52,10 +52,9 @@ await db.ready();
5252
5353// 3. Use the table() API
5454// The '$' symbol is automatically replaced by the table name ('users')
55- const users = db .table (' users' );
5655
5756// Create Table
58- await users .exec (`
57+ await db . table ( ' users' ) .exec (`
5958 CREATE TABLE IF NOT EXISTS $ (
6059 id INTEGER PRIMARY KEY AUTOINCREMENT,
6160 name TEXT NOT NULL,
@@ -64,10 +63,12 @@ await users.exec(`
6463` );
6564
6665// Insert (Fully typed params are not enforced yet, but return types are)
67- await users .run (' INSERT INTO $ (name, email) VALUES (?, ?)' , [' Alice' , ' alice@dev.com' ]);
66+ await db
67+ .table (' users' )
68+ .run (' INSERT INTO $ (name, email) VALUES (?, ?)' , [' Alice' , ' alice@dev.com' ]);
6869
6970// Query (Returns User[])
70- const allUsers = await users .query (' SELECT * FROM $' );
71+ const allUsers = await db . table ( ' users' ) .query (' SELECT * FROM $' );
7172```
7273
7374## Configuration
@@ -119,24 +120,34 @@ Key interfaces for better TypeScript integration.
119120
120121``` typescript
121122interface SQLiteWASMConfig {
122- filename: string ;
123+ filename: string ; // Required: Database file name
123124 vfs? : {
124- type? : ' opfs' | ' opfs-sahpool' | ' memdb' ;
125+ type? : ' opfs' | ' opfs-sahpool' | ' memdb' ; // Default: 'opfs'
126+ poolConfig? : {
127+ // Only used when type is 'opfs-sahpool'
128+ initialCapacity? : number ; // Default: 3
129+ clearOnInit? : boolean ; // Default: false
130+ name? : string ; // Default: 'sqlite-wasm-pool'
131+ };
125132 };
126133 pragma? : {
127- journal_mode? : ' DELETE' | ' TRUNCATE' | ' PERSIST' | ' MEMORY' | ' WAL' | ' OFF' ;
128- synchronous? : ' OFF' | ' NORMAL' | ' FULL' | ' EXTRA' ;
129- temp_store? : ' DEFAULT' | ' FILE' | ' MEMORY' ;
130- foreign_keys? : ' ON' | ' OFF' ;
134+ journal_mode? : ' DELETE' | ' TRUNCATE' | ' PERSIST' | ' MEMORY' | ' WAL' | ' OFF' ; // Default: 'WAL'
135+ synchronous? : ' OFF' | ' NORMAL' | ' FULL' | ' EXTRA' ; // Default: 'NORMAL'
136+ temp_store? : ' DEFAULT' | ' FILE' | ' MEMORY' ; // Default: 'MEMORY'
137+ foreign_keys? : ' ON' | ' OFF' ; // Default: undefined (not set)
131138 };
132139 logging? : {
133- filterSqlTrace? : boolean ;
134- print? : (message : string ) => void ;
135- printErr? : (message : string ) => void ;
140+ filterSqlTrace? : boolean ; // Default: true
141+ print? : (message : string ) => void ; // Default: console.log
142+ printErr? : (message : string ) => void ; // Default: console.error
136143 };
137144}
138145```
139146
147+ > ** Note:** The ` opfs ` VFS requires your server to set COOP/COEP headers
148+ > (` Cross-Origin-Opener-Policy: same-origin ` and ` Cross-Origin-Embedder-Policy: require-corp ` ). If
149+ > these headers are not available, use ` opfs-sahpool ` instead, which works without them.
150+
140151### ` RunResult `
141152
142153Returned by ` run() ` and ` table().run() ` .
0 commit comments