@nextlyhq/adapter-sqlite 0.0.2-alpha.67 → 0.0.2-alpha.69
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 +5 -5
- package/dist/index.cjs +871 -840
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +277 -313
- package/dist/index.d.ts +277 -313
- package/dist/index.mjs +869 -837
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -16
package/dist/index.d.ts
CHANGED
|
@@ -1,49 +1,11 @@
|
|
|
1
|
-
import { DrizzleAdapter } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { AnyRelations } from
|
|
5
|
-
import { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @nextlyhq/adapter-sqlite
|
|
9
|
-
*
|
|
10
|
-
* SQLite database adapter for Nextly.
|
|
11
|
-
* Extends DrizzleAdapter from @nextlyhq/adapter-drizzle to provide SQLite-specific functionality.
|
|
12
|
-
*
|
|
13
|
-
* @remarks
|
|
14
|
-
* This adapter uses the better-sqlite3 package for database connectivity and provides:
|
|
15
|
-
* - Synchronous API wrapped for async interface compatibility
|
|
16
|
-
* - Transactions the adapter runs itself (BEGIN IMMEDIATE / COMMIT / ROLLBACK), with nested calls run as savepoints
|
|
17
|
-
* - CRUD operations with RETURNING clause support (SQLite 3.35+)
|
|
18
|
-
* - WAL mode for better concurrent read performance
|
|
19
|
-
* - In-memory and file-based database support
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* import { createSqliteAdapter } from '@nextlyhq/adapter-sqlite';
|
|
24
|
-
*
|
|
25
|
-
* const adapter = createSqliteAdapter({
|
|
26
|
-
* url: 'file:./data/app.db',
|
|
27
|
-
* });
|
|
28
|
-
*
|
|
29
|
-
* await adapter.connect();
|
|
30
|
-
*
|
|
31
|
-
* // Query data
|
|
32
|
-
* const users = await adapter.select('users', {
|
|
33
|
-
* where: { and: [{ column: 'status', op: '=', value: 'active' }] },
|
|
34
|
-
* limit: 10,
|
|
35
|
-
* });
|
|
36
|
-
*
|
|
37
|
-
* await adapter.disconnect();
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* @packageDocumentation
|
|
41
|
-
*/
|
|
42
|
-
|
|
1
|
+
import { DrizzleAdapter } from "@nextlyhq/adapter-drizzle";
|
|
2
|
+
import { AdapterLogger, BaseAdapterConfig, DatabaseCapabilities, DatabaseError, DatabaseErrorKind, DeleteOptions, InsertOptions, JoinSpec, OrderBySpec, PoolStats, SelectOptions, SqlParam, SqliteAdapterConfig, TransactionContext, TransactionOptions, UpdateOptions, UpsertOptions, WhereClause, WhereCondition, WhereOperator } from "@nextlyhq/adapter-drizzle/types";
|
|
3
|
+
import { BetterSQLite3Database } from "drizzle-orm/better-sqlite3";
|
|
4
|
+
import { AnyRelations } from "drizzle-orm";
|
|
43
5
|
/**
|
|
44
6
|
* Package version
|
|
45
7
|
*/
|
|
46
|
-
declare const VERSION = "0.1.0";
|
|
8
|
+
export declare const VERSION = "0.1.0";
|
|
47
9
|
/**
|
|
48
10
|
* SQLite database adapter for Nextly.
|
|
49
11
|
*
|
|
@@ -69,272 +31,274 @@ declare const VERSION = "0.1.0";
|
|
|
69
31
|
* await adapter.connect();
|
|
70
32
|
* ```
|
|
71
33
|
*/
|
|
72
|
-
declare class SqliteAdapter extends DrizzleAdapter {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
34
|
+
export declare class SqliteAdapter extends DrizzleAdapter {
|
|
35
|
+
private drizzleByRelations;
|
|
36
|
+
private drizzleBare;
|
|
37
|
+
/**
|
|
38
|
+
* The database dialect - always 'sqlite' for this adapter.
|
|
39
|
+
*/
|
|
40
|
+
readonly dialect: "sqlite";
|
|
41
|
+
/**
|
|
42
|
+
* Adapter configuration.
|
|
43
|
+
*/
|
|
44
|
+
protected readonly config: SqliteAdapterConfig;
|
|
45
|
+
/**
|
|
46
|
+
* better-sqlite3 Database instance.
|
|
47
|
+
*/
|
|
48
|
+
private db;
|
|
49
|
+
/**
|
|
50
|
+
* Connection state flag.
|
|
51
|
+
*/
|
|
52
|
+
private connected;
|
|
53
|
+
/**
|
|
54
|
+
* Serialization queue for concurrent `transaction()` calls.
|
|
55
|
+
*
|
|
56
|
+
* better-sqlite3 is synchronous, single-connection, and rejects nested
|
|
57
|
+
* `BEGIN` with "cannot start a transaction within a transaction".
|
|
58
|
+
* When two `await adapter.transaction(...)` calls overlap (e.g. a bulk
|
|
59
|
+
* mutation calling `Promise.allSettled` with N per-row updates), the
|
|
60
|
+
* second one tries to BEGIN while the first is still open and the
|
|
61
|
+
* driver throws.
|
|
62
|
+
*
|
|
63
|
+
* Postgres/MySQL avoid this by allocating a fresh client/connection
|
|
64
|
+
* per transaction from a pool — there is no equivalent for
|
|
65
|
+
* better-sqlite3, so we serialize at the JS layer instead. Every
|
|
66
|
+
* `transaction()` invocation chains onto this promise; only one
|
|
67
|
+
* BEGIN→COMMIT/ROLLBACK section runs at any moment, preserving
|
|
68
|
+
* write-isolation semantics that callers expect from a transactional
|
|
69
|
+
* adapter.
|
|
70
|
+
*
|
|
71
|
+
* Performance impact is the natural floor: SQLite already serializes
|
|
72
|
+
* writers at the file-lock level, so the queue removes failed-call
|
|
73
|
+
* surface area without changing the achievable concurrency.
|
|
74
|
+
*/
|
|
75
|
+
private transactionQueue;
|
|
76
|
+
/**
|
|
77
|
+
* The transaction the current async chain is running inside, if any.
|
|
78
|
+
*
|
|
79
|
+
* A `transaction()` call made from INSIDE a transaction's work — a store
|
|
80
|
+
* writing on behalf of the caller, a plugin's write inside its own
|
|
81
|
+
* `ctx.db.transaction` — used to queue behind the very transaction that
|
|
82
|
+
* was waiting for it, and neither ever settled: that hung every later
|
|
83
|
+
* transaction on the instance too. Such a call now runs as a SAVEPOINT of
|
|
84
|
+
* the active transaction instead, so it commits or rolls back with it and
|
|
85
|
+
* its own failure undoes only its own part.
|
|
86
|
+
*/
|
|
87
|
+
private readonly transactionScope;
|
|
88
|
+
/**
|
|
89
|
+
* Creates a new SQLite adapter instance.
|
|
90
|
+
*
|
|
91
|
+
* @param config - Adapter configuration
|
|
92
|
+
*/
|
|
93
|
+
constructor(config: SqliteAdapterConfig);
|
|
94
|
+
/**
|
|
95
|
+
* Connect to the SQLite database.
|
|
96
|
+
*
|
|
97
|
+
* @remarks
|
|
98
|
+
* This method initializes the database connection. For SQLite, this
|
|
99
|
+
* opens the database file or creates an in-memory database.
|
|
100
|
+
* Also configures WAL mode and foreign keys based on config.
|
|
101
|
+
*
|
|
102
|
+
* @throws {DatabaseError} If connection fails
|
|
103
|
+
*/
|
|
104
|
+
connect(): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Disconnect from the SQLite database.
|
|
107
|
+
*
|
|
108
|
+
* @remarks
|
|
109
|
+
* This method closes the database connection and releases resources.
|
|
110
|
+
*/
|
|
111
|
+
disconnect(): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Check if connected to the database.
|
|
114
|
+
*/
|
|
115
|
+
isConnected(): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Get connection pool statistics.
|
|
118
|
+
*
|
|
119
|
+
* @remarks
|
|
120
|
+
* SQLite doesn't use connection pooling, so this returns null.
|
|
121
|
+
* The database is single-file with a single connection.
|
|
122
|
+
*/
|
|
123
|
+
getPoolStats(): PoolStats | null;
|
|
124
|
+
/**
|
|
125
|
+
* Execute a raw SQL query.
|
|
126
|
+
*
|
|
127
|
+
* @param sql - SQL query string with $1, $2 placeholders (converted to ? for SQLite)
|
|
128
|
+
* @param params - Query parameters
|
|
129
|
+
* @returns Query results
|
|
130
|
+
*
|
|
131
|
+
* @throws {DatabaseError} If query execution fails
|
|
132
|
+
*/
|
|
133
|
+
executeQuery<T = unknown>(sql: string, params?: SqlParam[]): Promise<T[]>;
|
|
134
|
+
/**
|
|
135
|
+
* Execute work within a transaction.
|
|
136
|
+
*
|
|
137
|
+
* @param work - Function containing transactional operations
|
|
138
|
+
* @param options - Transaction options (isolation level not fully supported in SQLite)
|
|
139
|
+
* @returns Result of the work function
|
|
140
|
+
*
|
|
141
|
+
* @remarks
|
|
142
|
+
* The adapter manages the transaction itself, because better-sqlite3's
|
|
143
|
+
* `db.transaction()` does not take async work: it runs `BEGIN IMMEDIATE`,
|
|
144
|
+
* then `COMMIT` when `work` resolves or `ROLLBACK` when it throws.
|
|
145
|
+
* - Top-level calls run one at a time.
|
|
146
|
+
* - A call made inside an open transaction's work joins it as a savepoint
|
|
147
|
+
* (`SAVEPOINT` / `RELEASE` / `ROLLBACK TO`).
|
|
148
|
+
* - Nested calls of one scope run one at a time.
|
|
149
|
+
* - A call made later from a savepoint that has already released joins the
|
|
150
|
+
* innermost scope still open.
|
|
151
|
+
* - Nested work started and not awaited finishes before the enclosing scope
|
|
152
|
+
* commits or rolls back.
|
|
153
|
+
*
|
|
154
|
+
* Note: SQLite uses DEFERRED, IMMEDIATE, or EXCLUSIVE transaction modes
|
|
155
|
+
* rather than isolation levels. This adapter uses IMMEDIATE.
|
|
156
|
+
*/
|
|
157
|
+
/** How long a transaction waits for the connection: `pool.connectionTimeoutMs`. */
|
|
158
|
+
private transactionWaitMs;
|
|
159
|
+
transaction<T>(work: (tx: TransactionContext) => Promise<T>, _options?: TransactionOptions): Promise<T>;
|
|
160
|
+
/**
|
|
161
|
+
* Hold `effect` until the transaction enclosing this async context commits,
|
|
162
|
+
* or run it now when none does.
|
|
163
|
+
*
|
|
164
|
+
* The effect belongs to the scope this async context runs in, even one
|
|
165
|
+
* that has already released or rolled back: a service whose own
|
|
166
|
+
* transaction nested as a savepoint registers from its caller's scope once
|
|
167
|
+
* that savepoint has released, and the change is undoable for as long as
|
|
168
|
+
* any scope around it is. The outermost transaction runs the effect once
|
|
169
|
+
* its COMMIT succeeds, unless a scope between the effect's scope and the
|
|
170
|
+
* outermost transaction rolled back, and drops every effect on ROLLBACK or
|
|
171
|
+
* a failed COMMIT. A context whose outermost transaction has already
|
|
172
|
+
* finished is outside any transaction, so its effect runs now, unless what
|
|
173
|
+
* it announces was undone and it has run no transaction since.
|
|
174
|
+
*/
|
|
175
|
+
override afterCommit(effect: () => unknown, onDeferredFailure?: (error: unknown) => void): Promise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* `effect`, bound to the async context it is registered from.
|
|
178
|
+
*
|
|
179
|
+
* A held effect runs after the outermost COMMIT, from the code that ran the
|
|
180
|
+
* outermost transaction, so without this it sees that code's context rather
|
|
181
|
+
* than its own: whatever its caller pinned around the write is gone. That
|
|
182
|
+
* includes who is calling. A scope pinned for a scoped API key lost there
|
|
183
|
+
* leaves a hook's nested call judged by the key's owner instead of the key,
|
|
184
|
+
* and a person's frame lost there leaves the hook told of nobody.
|
|
185
|
+
*
|
|
186
|
+
* The adapter's own transaction scope is the one store it leaves: the
|
|
187
|
+
* effect runs once that transaction has finished, outside it, as an effect
|
|
188
|
+
* held to the outermost commit always has.
|
|
189
|
+
*/
|
|
190
|
+
private inRegisteringContext;
|
|
191
|
+
/**
|
|
192
|
+
* Run the effects a committed transaction held, in order. A failure is
|
|
193
|
+
* reported, never thrown: the change is durable, and reporting the
|
|
194
|
+
* transaction as failed would invite a retry of something already done.
|
|
195
|
+
*/
|
|
196
|
+
private runHeldEffects;
|
|
197
|
+
/** Hand a held effect's failure to its reporter, or to the adapter's log. */
|
|
198
|
+
private reportHeldEffectFailure;
|
|
199
|
+
/**
|
|
200
|
+
* Whether a `transaction()` call made here would join an open transaction
|
|
201
|
+
* as a savepoint. On SQLite it would: the connection is the only one, so a
|
|
202
|
+
* transaction open on it encloses whatever the async chain that opened it
|
|
203
|
+
* starts.
|
|
204
|
+
*/
|
|
205
|
+
override inTransaction(): boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Whether the calling async flow is inside a transaction that has not
|
|
208
|
+
* finished, judged from the transaction this flow was started inside,
|
|
209
|
+
* never from the connection: another request's open transaction answers
|
|
210
|
+
* false here, where its own `transaction()` queues behind that one.
|
|
211
|
+
*
|
|
212
|
+
* A flow started inside a transaction, even inside a savepoint that has
|
|
213
|
+
* since released, stays inside it until its outermost transaction has
|
|
214
|
+
* committed or rolled back: until then whatever it writes on the one
|
|
215
|
+
* connection lands in that transaction.
|
|
216
|
+
*/
|
|
217
|
+
override transactionOpenInFlow(): boolean;
|
|
218
|
+
/**
|
|
219
|
+
* The scope a `transaction()` call made here nests in, or none when it
|
|
220
|
+
* opens a transaction of its own.
|
|
221
|
+
*
|
|
222
|
+
* A call made later from inside a savepoint that has since released runs
|
|
223
|
+
* inside the innermost scope open on the connection. Queued on an enclosing
|
|
224
|
+
* scope, or on the instance, it would wait behind the scope running there,
|
|
225
|
+
* which may be the one awaiting it. Savepoints on one connection form a
|
|
226
|
+
* stack, so whatever opens now is inside that innermost scope anyway; when
|
|
227
|
+
* none is open the call queues on the instance.
|
|
228
|
+
*
|
|
229
|
+
* The innermost open scope need not be related to the call. When it is a
|
|
230
|
+
* sibling savepoint that later rolls back, the call's write rolls back with
|
|
231
|
+
* it, although the call itself already resolved. Waiting for an unrelated
|
|
232
|
+
* scope instead could wait on the very scope that awaits the call.
|
|
233
|
+
*/
|
|
234
|
+
private nestingScope;
|
|
235
|
+
/**
|
|
236
|
+
* Run `work` as a savepoint of the active transaction: released when it
|
|
237
|
+
* resolves, rolled back to when it throws.
|
|
238
|
+
*/
|
|
239
|
+
private runSavepoint;
|
|
240
|
+
/**
|
|
241
|
+
* Inner transaction body. Kept private so callers always go through
|
|
242
|
+
* the serialized `transaction()` queue above and the BEGIN/COMMIT
|
|
243
|
+
* pair is never invoked outside of it.
|
|
244
|
+
*/
|
|
245
|
+
private runTransaction;
|
|
246
|
+
/**
|
|
247
|
+
* Get SQLite database capabilities.
|
|
248
|
+
*
|
|
249
|
+
* @remarks
|
|
250
|
+
* SQLite capabilities:
|
|
251
|
+
* - JSON support (not JSONB)
|
|
252
|
+
* - No arrays
|
|
253
|
+
* - No native ILIKE
|
|
254
|
+
* - RETURNING clause (3.35+)
|
|
255
|
+
* - Savepoints supported
|
|
256
|
+
* - ON CONFLICT supported
|
|
257
|
+
*/
|
|
258
|
+
getCapabilities(): DatabaseCapabilities;
|
|
259
|
+
/**
|
|
260
|
+
* Override insertMany for bulk insert optimization.
|
|
261
|
+
*
|
|
262
|
+
* @remarks
|
|
263
|
+
* Uses a single multi-row INSERT statement for better performance.
|
|
264
|
+
*/
|
|
265
|
+
override insertMany<T = unknown>(table: string, data: Record<string, unknown>[], options?: InsertOptions): Promise<T[]>;
|
|
266
|
+
/**
|
|
267
|
+
* Ensures database is connected and returns it.
|
|
268
|
+
*
|
|
269
|
+
* @throws {DatabaseError} If not connected
|
|
270
|
+
*/
|
|
271
|
+
private ensureDb;
|
|
272
|
+
/**
|
|
273
|
+
* Return the typed Drizzle instance for SQLite.
|
|
274
|
+
* Guarded for server-only usage and requires an active connection.
|
|
275
|
+
*
|
|
276
|
+
* @param schema - Optional schema for relational queries (db.query.*)
|
|
277
|
+
* @returns Drizzle ORM instance wrapping the better-sqlite3 connection
|
|
278
|
+
* @throws {Error} If called in browser or not connected
|
|
279
|
+
*/
|
|
280
|
+
getDrizzle<T = BetterSQLite3Database<AnyRelations>>(relations?: AnyRelations): T;
|
|
281
|
+
/**
|
|
282
|
+
* Convert $1, $2 placeholders to ? for better-sqlite3.
|
|
283
|
+
*
|
|
284
|
+
* @param sql - SQL with PostgreSQL-style placeholders
|
|
285
|
+
* @returns SQL with ? placeholders
|
|
286
|
+
*/
|
|
287
|
+
private convertPlaceholders;
|
|
288
|
+
/**
|
|
289
|
+
* Creates a TransactionContext for the given database connection.
|
|
290
|
+
*/
|
|
291
|
+
/** A table-level `primaryKey({ columns })`, read through the SQLite table config. */
|
|
292
|
+
protected override compositePrimaryKey(tableObj: Record<string, unknown>): object[];
|
|
293
|
+
private createTransactionContext;
|
|
294
|
+
/**
|
|
295
|
+
* Classifies a SQLite error into a DatabaseError.
|
|
296
|
+
*
|
|
297
|
+
* @param error - Original error from better-sqlite3
|
|
298
|
+
* @param sql - SQL statement that caused the error (optional)
|
|
299
|
+
* @returns DatabaseError with proper classification
|
|
300
|
+
*/
|
|
301
|
+
protected override classifyError(error: unknown, sql?: string): DatabaseError;
|
|
338
302
|
}
|
|
339
303
|
/**
|
|
340
304
|
* Create a SQLite database adapter.
|
|
@@ -368,7 +332,7 @@ declare class SqliteAdapter extends DrizzleAdapter {
|
|
|
368
332
|
* await adapter.connect();
|
|
369
333
|
* ```
|
|
370
334
|
*/
|
|
371
|
-
declare function createSqliteAdapter(config: SqliteAdapterConfig): SqliteAdapter;
|
|
335
|
+
export declare function createSqliteAdapter(config: SqliteAdapterConfig): SqliteAdapter;
|
|
372
336
|
/**
|
|
373
337
|
* Type guard to check if a value is a SqliteAdapter.
|
|
374
338
|
*
|
|
@@ -383,6 +347,6 @@ declare function createSqliteAdapter(config: SqliteAdapterConfig): SqliteAdapter
|
|
|
383
347
|
* }
|
|
384
348
|
* ```
|
|
385
349
|
*/
|
|
386
|
-
declare function isSqliteAdapter(value: unknown): value is SqliteAdapter;
|
|
387
|
-
|
|
388
|
-
|
|
350
|
+
export declare function isSqliteAdapter(value: unknown): value is SqliteAdapter;
|
|
351
|
+
export type { AdapterLogger, BaseAdapterConfig, DatabaseCapabilities, DatabaseError, DatabaseErrorKind, DeleteOptions, InsertOptions, JoinSpec, OrderBySpec, PoolStats, SelectOptions, SqlParam, SqliteAdapterConfig, TransactionContext, TransactionOptions, UpdateOptions, UpsertOptions, WhereClause, WhereCondition, WhereOperator };
|
|
352
|
+
//# sourceMappingURL=index.d.ts.map
|