@nextlyhq/adapter-drizzle 0.0.2-alpha.68 → 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/dist/adapter-BypoOEEN.d.cts +1166 -0
- package/dist/adapter-CSP-Ek-L.d.ts +1166 -0
- package/dist/index-BYb6cDli.d.ts +1168 -0
- package/dist/index-C4HJsfwA.d.cts +1168 -0
- package/dist/index.cjs +2258 -2183
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -10
- package/dist/index.d.ts +5 -10
- package/dist/index.mjs +2257 -2181
- package/dist/index.mjs.map +1 -1
- package/dist/migrations.cjs +345 -146
- package/dist/migrations.cjs.map +1 -1
- package/dist/migrations.d.cts +93 -110
- package/dist/migrations.d.ts +93 -110
- package/dist/migrations.mjs +344 -144
- package/dist/migrations.mjs.map +1 -1
- package/dist/schema/index.cjs +21 -6
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +5 -116
- package/dist/schema/index.d.ts +5 -116
- package/dist/schema/index.mjs +20 -4
- package/dist/schema/index.mjs.map +1 -1
- package/dist/schema-Bkkr3JMC.d.cts +264 -0
- package/dist/schema-Bkkr3JMC.d.ts +264 -0
- package/dist/schema-name.cjs +34 -12
- package/dist/schema-name.cjs.map +1 -1
- package/dist/schema-name.d.cts +3 -15
- package/dist/schema-name.d.ts +3 -15
- package/dist/schema-name.mjs +33 -10
- package/dist/schema-name.mjs.map +1 -1
- package/dist/text-match.cjs +42 -8
- package/dist/text-match.cjs.map +1 -1
- package/dist/text-match.d.cts +4 -16
- package/dist/text-match.d.ts +4 -16
- package/dist/text-match.mjs +41 -6
- package/dist/text-match.mjs.map +1 -1
- package/dist/types/index.cjs +8 -69
- package/dist/types/index.d.cts +3 -225
- package/dist/types/index.d.ts +3 -225
- package/dist/types/index.mjs +1 -64
- package/dist/types-CNyA1oIm.cjs +185 -0
- package/dist/types-CNyA1oIm.cjs.map +1 -0
- package/dist/types-CaF_5jNk.mjs +150 -0
- package/dist/types-CaF_5jNk.mjs.map +1 -0
- package/dist/version-check.cjs +116 -133
- package/dist/version-check.cjs.map +1 -1
- package/dist/version-check.d.cts +46 -47
- package/dist/version-check.d.ts +46 -47
- package/dist/version-check.mjs +115 -131
- package/dist/version-check.mjs.map +1 -1
- package/package.json +12 -16
- package/dist/adapter-bUAaPzjV.d.cts +0 -1143
- package/dist/adapter-iJ5hbUvL.d.ts +0 -1143
- package/dist/core-CVO7WYDj.d.cts +0 -74
- package/dist/core-CVO7WYDj.d.ts +0 -74
- package/dist/error-BrdknH2s.d.cts +0 -122
- package/dist/error-BrdknH2s.d.ts +0 -122
- package/dist/migration-BqHebSwM.d.ts +0 -831
- package/dist/migration-Bu0WLdX4.d.cts +0 -831
- package/dist/schema-BDn8WfSL.d.cts +0 -200
- package/dist/schema-BIQ0YQZ_.d.ts +0 -200
- package/dist/types/index.cjs.map +0 -1
- package/dist/types/index.mjs.map +0 -1
|
@@ -1,831 +0,0 @@
|
|
|
1
|
-
import { a as SqlParam, S as SupportedDialect } from './core-CVO7WYDj.cjs';
|
|
2
|
-
import { AnyRelations, SQL } from 'drizzle-orm';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Query building type definitions for database-agnostic queries.
|
|
6
|
-
*
|
|
7
|
-
* @packageDocumentation
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Every WHERE clause operator this package DECLARES, as a value.
|
|
12
|
-
*
|
|
13
|
-
* @remarks
|
|
14
|
-
* Declared, not guaranteed executable. Membership here means a `WhereCondition`
|
|
15
|
-
* carrying the operator type-checks — it does NOT mean the adapter can run it.
|
|
16
|
-
* `OVERLAPS` is declared and unimplemented, and throws at build time, so a
|
|
17
|
-
* validator written against this list will admit input the query layer then
|
|
18
|
-
* rejects. Validate against it to catch a misspelled operator; do not read
|
|
19
|
-
* acceptance here as a capability.
|
|
20
|
-
*
|
|
21
|
-
* - Standard comparison: =, !=, <, >, <=, >=
|
|
22
|
-
* - Set operations: IN, NOT IN
|
|
23
|
-
* - Pattern matching: LIKE, ILIKE (case-insensitive, PostgreSQL/emulated)
|
|
24
|
-
* - NULL checks: IS NULL, IS NOT NULL
|
|
25
|
-
* - Range: BETWEEN, NOT BETWEEN
|
|
26
|
-
* - Substring: CONTAINS — a LITERAL match on a TEXT column; see below
|
|
27
|
-
* - Declared but NOT implemented: OVERLAPS, which throws
|
|
28
|
-
*
|
|
29
|
-
* This list is the source of truth and {@link WhereOperator} is derived from it,
|
|
30
|
-
* rather than the two being written out separately. A guard that has to enumerate
|
|
31
|
-
* the operators — a validator over caller input, or a test asserting the builder
|
|
32
|
-
* handles or refuses each one — can only do that from a runtime value, and a
|
|
33
|
-
* hand-kept copy of the union would agree with it on the day it was written and
|
|
34
|
-
* silently stop agreeing the next time a member is added.
|
|
35
|
-
*
|
|
36
|
-
* @public
|
|
37
|
-
*/
|
|
38
|
-
declare const WHERE_OPERATORS: readonly ["=", "!=", "<", ">", "<=", ">=", "IN", "NOT IN", "LIKE", "ILIKE", "IS NULL", "IS NOT NULL", "BETWEEN", "NOT BETWEEN", "CONTAINS", "ICONTAINS", "OVERLAPS"];
|
|
39
|
-
/**
|
|
40
|
-
* Every WHERE clause operator this package declares. Derived from
|
|
41
|
-
* {@link WHERE_OPERATORS}, and carrying the same caveat: a value of this type
|
|
42
|
-
* type-checks, which is not the same as the adapter being able to execute it.
|
|
43
|
-
*
|
|
44
|
-
* @public
|
|
45
|
-
*/
|
|
46
|
-
type WhereOperator = (typeof WHERE_OPERATORS)[number];
|
|
47
|
-
/**
|
|
48
|
-
* Individual WHERE condition.
|
|
49
|
-
*
|
|
50
|
-
* @remarks
|
|
51
|
-
* Represents a single condition in a WHERE clause. For IS NULL and IS NOT NULL
|
|
52
|
-
* operators, the value field is optional.
|
|
53
|
-
*
|
|
54
|
-
* @public
|
|
55
|
-
*/
|
|
56
|
-
interface WhereCondition {
|
|
57
|
-
/** Column name to filter on */
|
|
58
|
-
column: string;
|
|
59
|
-
/** Comparison operator */
|
|
60
|
-
op: WhereOperator;
|
|
61
|
-
/** Value(s) to compare against (optional for IS NULL/IS NOT NULL) */
|
|
62
|
-
value?: SqlParam | SqlParam[];
|
|
63
|
-
/** Second value for BETWEEN operator */
|
|
64
|
-
valueTo?: SqlParam;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Complex WHERE clause with logical operators.
|
|
68
|
-
*
|
|
69
|
-
* @remarks
|
|
70
|
-
* Supports nested conditions with AND, OR, and NOT logical operators.
|
|
71
|
-
* Can be recursively nested for complex queries.
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```typescript
|
|
75
|
-
* const where: WhereClause = {
|
|
76
|
-
* and: [
|
|
77
|
-
* { column: "status", op: "=", value: "published" },
|
|
78
|
-
* {
|
|
79
|
-
* or: [
|
|
80
|
-
* { column: "author", op: "=", value: "john" },
|
|
81
|
-
* { column: "author", op: "=", value: "jane" }
|
|
82
|
-
* ]
|
|
83
|
-
* }
|
|
84
|
-
* ]
|
|
85
|
-
* };
|
|
86
|
-
* ```
|
|
87
|
-
*
|
|
88
|
-
* @public
|
|
89
|
-
*/
|
|
90
|
-
interface WhereClause {
|
|
91
|
-
/** All conditions must be true (AND) */
|
|
92
|
-
and?: (WhereCondition | WhereClause)[];
|
|
93
|
-
/** At least one condition must be true (OR) */
|
|
94
|
-
or?: (WhereCondition | WhereClause)[];
|
|
95
|
-
/** Negate a condition (NOT) */
|
|
96
|
-
not?: WhereCondition | WhereClause;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* ORDER BY specification for query results.
|
|
100
|
-
*
|
|
101
|
-
* @remarks
|
|
102
|
-
* Controls the sorting of query results. NULL handling varies by database
|
|
103
|
-
* but can be explicitly controlled with the nulls field.
|
|
104
|
-
*
|
|
105
|
-
* @public
|
|
106
|
-
*/
|
|
107
|
-
interface OrderBySpec {
|
|
108
|
-
/** Column name to sort by */
|
|
109
|
-
column: string;
|
|
110
|
-
/** Sort direction (default: asc) */
|
|
111
|
-
direction?: "asc" | "desc";
|
|
112
|
-
/** NULL value ordering (database-specific defaults vary) */
|
|
113
|
-
nulls?: "first" | "last";
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* JOIN specification for table joins.
|
|
117
|
-
*
|
|
118
|
-
* @remarks
|
|
119
|
-
* Supports different types of JOINs. Note that complex joins may require
|
|
120
|
-
* dialect-specific handling.
|
|
121
|
-
*
|
|
122
|
-
* @public
|
|
123
|
-
*/
|
|
124
|
-
interface JoinSpec {
|
|
125
|
-
/** Type of join */
|
|
126
|
-
type: "inner" | "left" | "right" | "full";
|
|
127
|
-
/** Table name to join */
|
|
128
|
-
table: string;
|
|
129
|
-
/** Join condition */
|
|
130
|
-
on: {
|
|
131
|
-
/** Column from the left table */
|
|
132
|
-
leftColumn: string;
|
|
133
|
-
/** Column from the right table */
|
|
134
|
-
rightColumn: string;
|
|
135
|
-
};
|
|
136
|
-
/** Optional alias for the joined table */
|
|
137
|
-
alias?: string;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* CRUD operation type definitions.
|
|
142
|
-
*
|
|
143
|
-
* @packageDocumentation
|
|
144
|
-
*/
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Options for SELECT queries.
|
|
148
|
-
*
|
|
149
|
-
* @remarks
|
|
150
|
-
* Provides a database-agnostic way to build SELECT queries with filtering,
|
|
151
|
-
* sorting, pagination, and joins.
|
|
152
|
-
*
|
|
153
|
-
* @public
|
|
154
|
-
*/
|
|
155
|
-
/**
|
|
156
|
-
* What a COUNT asks for.
|
|
157
|
-
*
|
|
158
|
-
* 🔴 `distinctOn` is a column LIST rather than a boolean, and the difference is
|
|
159
|
-
* the whole reason this option exists: counting rows and counting the things
|
|
160
|
-
* those rows are about are different questions whenever a thing can own more
|
|
161
|
-
* than one row. A document holding a pending edit in three languages is one
|
|
162
|
-
* document and three version rows.
|
|
163
|
-
*/
|
|
164
|
-
interface CountOptions {
|
|
165
|
-
/** Filter conditions, the same vocabulary `select` takes. */
|
|
166
|
-
where?: WhereClause;
|
|
167
|
-
/**
|
|
168
|
-
* Count DISTINCT combinations of these columns instead of rows.
|
|
169
|
-
*
|
|
170
|
-
* Compiled as `COUNT(*)` over a `SELECT DISTINCT` subquery rather than as
|
|
171
|
-
* `COUNT(DISTINCT a, b)`, because the latter is not portable: MySQL accepts
|
|
172
|
-
* it, PostgreSQL requires a row constructor, and SQLite rejects it outright
|
|
173
|
-
* with "wrong number of arguments to function count()". The subquery is the
|
|
174
|
-
* one form all three engines agree on, and it is what this compiles to on
|
|
175
|
-
* every dialect so the number cannot differ by engine.
|
|
176
|
-
*/
|
|
177
|
-
distinctOn?: string[];
|
|
178
|
-
}
|
|
179
|
-
interface SelectOptions {
|
|
180
|
-
/** Specific columns to select (default: all columns) */
|
|
181
|
-
columns?: string[];
|
|
182
|
-
/** Filter conditions */
|
|
183
|
-
where?: WhereClause;
|
|
184
|
-
/** Sort order */
|
|
185
|
-
orderBy?: OrderBySpec[];
|
|
186
|
-
/** Maximum number of rows to return */
|
|
187
|
-
limit?: number;
|
|
188
|
-
/** Number of rows to skip */
|
|
189
|
-
offset?: number;
|
|
190
|
-
/** Table joins */
|
|
191
|
-
joins?: JoinSpec[];
|
|
192
|
-
/** GROUP BY columns */
|
|
193
|
-
groupBy?: string[];
|
|
194
|
-
/** HAVING clause (for aggregated results) */
|
|
195
|
-
having?: WhereClause;
|
|
196
|
-
/** Return distinct rows only */
|
|
197
|
-
distinct?: boolean;
|
|
198
|
-
/**
|
|
199
|
-
* Take a `FOR UPDATE` row lock on the selected rows for the rest of the
|
|
200
|
-
* transaction, and read the latest committed values rather than the
|
|
201
|
-
* transaction's snapshot. Use for read-modify-write sequences that must not
|
|
202
|
-
* interleave (e.g. re-reading a status under the lock the write will take).
|
|
203
|
-
*
|
|
204
|
-
* Requires a transaction executor. No-ops on SQLite, which has no `FOR UPDATE`
|
|
205
|
-
* and needs none — its transactions open with `BEGIN IMMEDIATE`, already
|
|
206
|
-
* serializing writers.
|
|
207
|
-
*/
|
|
208
|
-
forUpdate?: boolean;
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Options for INSERT operations.
|
|
212
|
-
*
|
|
213
|
-
* @remarks
|
|
214
|
-
* Controls the behavior of INSERT operations including conflict handling
|
|
215
|
-
* and returning inserted data.
|
|
216
|
-
*
|
|
217
|
-
* @public
|
|
218
|
-
*/
|
|
219
|
-
interface InsertOptions {
|
|
220
|
-
/** Columns to return after insert (use "*" for all columns) */
|
|
221
|
-
returning?: string[] | "*";
|
|
222
|
-
/** Handle conflicts (unique constraint violations) */
|
|
223
|
-
onConflict?: {
|
|
224
|
-
/** Columns that define the conflict (unique constraint) */
|
|
225
|
-
columns: string[];
|
|
226
|
-
/** Action to take on conflict */
|
|
227
|
-
action: "ignore" | "update";
|
|
228
|
-
/** Columns to update on conflict (required if action is "update") */
|
|
229
|
-
updateColumns?: string[];
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Options for UPDATE operations.
|
|
234
|
-
*
|
|
235
|
-
* @remarks
|
|
236
|
-
* Controls what data is returned after an update operation.
|
|
237
|
-
*
|
|
238
|
-
* @public
|
|
239
|
-
*/
|
|
240
|
-
interface UpdateOptions {
|
|
241
|
-
/** Columns to return after update (use "*" for all columns) */
|
|
242
|
-
returning?: string[] | "*";
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Options for DELETE operations.
|
|
246
|
-
*
|
|
247
|
-
* @remarks
|
|
248
|
-
* Controls what data is returned after a delete operation.
|
|
249
|
-
*
|
|
250
|
-
* @public
|
|
251
|
-
*/
|
|
252
|
-
interface DeleteOptions {
|
|
253
|
-
/** Columns to return after delete (use "*" for all columns) */
|
|
254
|
-
returning?: string[] | "*";
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Options for UPSERT operations (INSERT or UPDATE).
|
|
258
|
-
*
|
|
259
|
-
* @remarks
|
|
260
|
-
* Combines INSERT and UPDATE behavior. If a row with the specified
|
|
261
|
-
* conflict columns exists, it will be updated; otherwise, a new row
|
|
262
|
-
* will be inserted.
|
|
263
|
-
*
|
|
264
|
-
* @public
|
|
265
|
-
*/
|
|
266
|
-
interface UpsertOptions {
|
|
267
|
-
/** Columns that define uniqueness for conflict detection */
|
|
268
|
-
conflictColumns: string[];
|
|
269
|
-
/**
|
|
270
|
-
* Columns to update if conflict occurs (default: all provided columns).
|
|
271
|
-
*
|
|
272
|
-
* Empty means "insert, or keep the row that stands". The kept row is read
|
|
273
|
-
* back after the statement, so on PostgreSQL and SQLite a row another
|
|
274
|
-
* writer deletes between the two cannot be returned, and the call resolves
|
|
275
|
-
* to `null`. Whether THIS call created the row is told by the id it
|
|
276
|
-
* returns: send a fresh id, and only a call whose own insert ran gets it
|
|
277
|
-
* back — a read-back can only return another writer's row.
|
|
278
|
-
*/
|
|
279
|
-
updateColumns?: string[];
|
|
280
|
-
/** Columns to return after upsert (use "*" for all columns) */
|
|
281
|
-
returning?: string[] | "*";
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Transaction type definitions for database operations.
|
|
286
|
-
*
|
|
287
|
-
* @packageDocumentation
|
|
288
|
-
*/
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Transaction isolation levels.
|
|
292
|
-
*
|
|
293
|
-
* @remarks
|
|
294
|
-
* Controls the visibility of changes between concurrent transactions.
|
|
295
|
-
* Not all levels are supported by all databases:
|
|
296
|
-
* - PostgreSQL: All levels supported
|
|
297
|
-
* - MySQL: All levels supported
|
|
298
|
-
* - SQLite: Serializable only (default)
|
|
299
|
-
*
|
|
300
|
-
* @public
|
|
301
|
-
*/
|
|
302
|
-
type TransactionIsolationLevel = "read uncommitted" | "read committed" | "repeatable read" | "serializable";
|
|
303
|
-
/**
|
|
304
|
-
* Options for transaction execution.
|
|
305
|
-
*
|
|
306
|
-
* @remarks
|
|
307
|
-
* Configures transaction behavior including isolation level, read-only mode,
|
|
308
|
-
* timeouts, and retry logic.
|
|
309
|
-
*
|
|
310
|
-
* @public
|
|
311
|
-
*/
|
|
312
|
-
interface TransactionOptions {
|
|
313
|
-
/** Transaction isolation level */
|
|
314
|
-
isolationLevel?: TransactionIsolationLevel;
|
|
315
|
-
/** Read-only transaction (optimization hint) */
|
|
316
|
-
readOnly?: boolean;
|
|
317
|
-
/** Per-transaction statement timeout in milliseconds */
|
|
318
|
-
timeoutMs?: number;
|
|
319
|
-
/** Number of retry attempts on serialization failures (default: 0) */
|
|
320
|
-
retryCount?: number;
|
|
321
|
-
/** Delay between retry attempts in milliseconds (default: 100) */
|
|
322
|
-
retryDelayMs?: number;
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Transaction context for executing operations within a transaction.
|
|
326
|
-
*
|
|
327
|
-
* @remarks
|
|
328
|
-
* All operations executed through this context are part of the same
|
|
329
|
-
* database transaction. The transaction is automatically committed on
|
|
330
|
-
* success or rolled back on error.
|
|
331
|
-
*
|
|
332
|
-
* Savepoint methods are optional and only available on databases that
|
|
333
|
-
* support them (PostgreSQL, SQLite).
|
|
334
|
-
*
|
|
335
|
-
* @public
|
|
336
|
-
*/
|
|
337
|
-
interface TransactionContext {
|
|
338
|
-
/**
|
|
339
|
-
* Execute raw SQL within the transaction.
|
|
340
|
-
*
|
|
341
|
-
* @param sql - SQL statement to execute
|
|
342
|
-
* @param params - Optional parameters for the statement
|
|
343
|
-
* @returns Array of result rows
|
|
344
|
-
*/
|
|
345
|
-
execute<T = unknown>(sql: string, params?: SqlParam[]): Promise<T[]>;
|
|
346
|
-
/**
|
|
347
|
-
* An instance bound to the SAME transaction client with the relational
|
|
348
|
-
* query API (`db.query.*`) enabled — the transaction's counterpart of
|
|
349
|
-
* `getDrizzle(relations)`.
|
|
350
|
-
*
|
|
351
|
-
* The `getDrizzle()` instance has an empty `query` namespace, so a
|
|
352
|
-
* relational read inside the transaction needs this one; the pooled
|
|
353
|
-
* `getDrizzle(relations)` would read on a different connection and miss the
|
|
354
|
-
* transaction's uncommitted writes. Memoized per relations object, as
|
|
355
|
-
* `getDrizzle` is, so repeated calls with an unchanged config share one
|
|
356
|
-
* instance.
|
|
357
|
-
*
|
|
358
|
-
* @param relations - drizzle v1 relations config (defineRelations output)
|
|
359
|
-
*/
|
|
360
|
-
drizzleWithRelations<T = unknown>(relations: AnyRelations): T;
|
|
361
|
-
/**
|
|
362
|
-
* Run a Drizzle-built statement within the transaction, for its effect.
|
|
363
|
-
*
|
|
364
|
-
* @remarks
|
|
365
|
-
* The typed CRUD methods below resolve their table through the schema
|
|
366
|
-
* registry and reject any name it does not declare. That leaves no way to
|
|
367
|
-
* write to a table addressed under a name the ORM does not know — a table
|
|
368
|
-
* mid-rename, most of all — other than assembling SQL by hand, which also
|
|
369
|
-
* means hand-picking each driver's placeholder syntax.
|
|
370
|
-
*
|
|
371
|
-
* This accepts Drizzle's `sql` template instead, so identifier quoting and
|
|
372
|
-
* parameter binding are generated for the dialect in use. Implemented per
|
|
373
|
-
* adapter because the underlying call is not uniform: node-postgres and
|
|
374
|
-
* mysql2 expose `execute`, while better-sqlite3 needs `run` and throws on a
|
|
375
|
-
* statement that returns no rows.
|
|
376
|
-
*
|
|
377
|
-
* Returns nothing: this is for statements run to change data, not to read it.
|
|
378
|
-
*
|
|
379
|
-
* @param statement - Drizzle `sql` template to run
|
|
380
|
-
*/
|
|
381
|
-
runStatement(statement: SQL): Promise<void>;
|
|
382
|
-
/**
|
|
383
|
-
* Run a Drizzle-built statement within the transaction and return its rows.
|
|
384
|
-
*
|
|
385
|
-
* @remarks
|
|
386
|
-
* The reading half of `runStatement`, for the same reason: a table the schema
|
|
387
|
-
* registry does not declare cannot be reached through the typed CRUD methods,
|
|
388
|
-
* which reject the name outright. Implemented per adapter because the drivers
|
|
389
|
-
* disagree about both the call and the result — node-postgres answers
|
|
390
|
-
* `{ rows }`, mysql2 a `[rows, fields]` tuple, and better-sqlite3 needs `all`.
|
|
391
|
-
*
|
|
392
|
-
* @param statement - Drizzle `sql` template to run
|
|
393
|
-
* @returns Rows the statement produced
|
|
394
|
-
*/
|
|
395
|
-
queryStatement<T = Record<string, unknown>>(statement: SQL): Promise<T[]>;
|
|
396
|
-
/**
|
|
397
|
-
* Take an exclusive lock on a single row for the rest of this transaction.
|
|
398
|
-
*
|
|
399
|
-
* @remarks
|
|
400
|
-
* For read-modify-write sequences that must not interleave: without a lock
|
|
401
|
-
* another transaction can commit between the read and the write, leaving the
|
|
402
|
-
* caller's view of the prior state inconsistent with what its own write
|
|
403
|
-
* applied on top of.
|
|
404
|
-
*
|
|
405
|
-
* No-ops on dialects without row-level locking. SQLite is the case that
|
|
406
|
-
* matters and needs nothing — its transactions open with `BEGIN IMMEDIATE`,
|
|
407
|
-
* which already serializes writers.
|
|
408
|
-
*
|
|
409
|
-
* @param table - Table name
|
|
410
|
-
* @param id - Primary-key value of the row to lock
|
|
411
|
-
*/
|
|
412
|
-
lockRow(table: string, id: SqlParam): Promise<void>;
|
|
413
|
-
/**
|
|
414
|
-
* Insert a single record.
|
|
415
|
-
*
|
|
416
|
-
* @param table - Table name
|
|
417
|
-
* @param data - Record data to insert
|
|
418
|
-
* @param options - Insert options
|
|
419
|
-
* @returns Inserted record (with RETURNING columns if specified)
|
|
420
|
-
*/
|
|
421
|
-
insert<T = unknown>(table: string, data: Record<string, unknown>, options?: InsertOptions): Promise<T>;
|
|
422
|
-
/**
|
|
423
|
-
* Insert multiple records.
|
|
424
|
-
*
|
|
425
|
-
* @param table - Table name
|
|
426
|
-
* @param data - Array of records to insert
|
|
427
|
-
* @param options - Insert options
|
|
428
|
-
* @returns Inserted records (with RETURNING columns if specified)
|
|
429
|
-
*/
|
|
430
|
-
insertMany<T = unknown>(table: string, data: Record<string, unknown>[], options?: InsertOptions): Promise<T[]>;
|
|
431
|
-
/**
|
|
432
|
-
* Select multiple records.
|
|
433
|
-
*
|
|
434
|
-
* @param table - Table name
|
|
435
|
-
* @param options - Select options (filtering, sorting, etc.)
|
|
436
|
-
* @returns Array of matching records
|
|
437
|
-
*/
|
|
438
|
-
select<T = unknown>(table: string, options?: SelectOptions): Promise<T[]>;
|
|
439
|
-
/**
|
|
440
|
-
* Select a single record.
|
|
441
|
-
*
|
|
442
|
-
* @param table - Table name
|
|
443
|
-
* @param options - Select options (filtering, sorting, etc.)
|
|
444
|
-
* @returns First matching record or null
|
|
445
|
-
*/
|
|
446
|
-
selectOne<T = unknown>(table: string, options?: SelectOptions): Promise<T | null>;
|
|
447
|
-
/**
|
|
448
|
-
* Update records.
|
|
449
|
-
*
|
|
450
|
-
* @remarks
|
|
451
|
-
* Built by the adapter rather than by the Drizzle query builder, as `insert`
|
|
452
|
-
* is: the statement writes the columns the PHYSICAL table has, where the
|
|
453
|
-
* pooled `update` writes the ones the runtime model declares. A column the
|
|
454
|
-
* model declares binds through its own encoder, exactly as the query builder
|
|
455
|
-
* binds it; one it does not declare binds the way this adapter's
|
|
456
|
-
* transactional insert binds every value; a key naming no column on the
|
|
457
|
-
* table is a database error rather than a silent drop. A key whose value is
|
|
458
|
-
* `undefined` is not written, `null` is, and an update naming nothing to
|
|
459
|
-
* write is refused.
|
|
460
|
-
*
|
|
461
|
-
* When `options.returning` asks for rows, they come from a read on this
|
|
462
|
-
* transaction, decoded as every read is — the model's view of the row,
|
|
463
|
-
* whatever columns were named. On PostgreSQL and SQLite that read is by the
|
|
464
|
-
* identities the statement reported through RETURNING, so it is exactly the
|
|
465
|
-
* rows this update changed. MySQL has no RETURNING, so there the read
|
|
466
|
-
* re-runs `where`, as it always has on that dialect: an update whose own
|
|
467
|
-
* write falsifies its `where` reads back nothing, and a row another
|
|
468
|
-
* transaction adds under the predicate meanwhile is included. A fenced
|
|
469
|
-
* compare-and-set wants `updateCount` on every dialect.
|
|
470
|
-
*
|
|
471
|
-
* @param table - Table name
|
|
472
|
-
* @param data - Data to update, keyed by SQL column name; Drizzle property
|
|
473
|
-
* names are accepted as well
|
|
474
|
-
* @param where - Conditions for records to update
|
|
475
|
-
* @param options - Update options
|
|
476
|
-
* @returns The updated rows when `returning` asked for them, else `[]`
|
|
477
|
-
*/
|
|
478
|
-
update<T = unknown>(table: string, data: Record<string, unknown>, where: WhereClause, options?: UpdateOptions): Promise<T[]>;
|
|
479
|
-
/**
|
|
480
|
-
* Update records and report how many rows the statement affected.
|
|
481
|
-
*
|
|
482
|
-
* @remarks
|
|
483
|
-
* The transactional half of the adapter's `updateCount`, and the only way to
|
|
484
|
-
* perform a fenced compare-and-set inside a transaction. `update` cannot
|
|
485
|
-
* answer this: without `returning` it discards the driver's count, and WITH
|
|
486
|
-
* `returning` on a dialect that lacks RETURNING it re-SELECTs using the same
|
|
487
|
-
* WHERE — so a conditional update whose own write falsifies its predicate
|
|
488
|
-
* reads back zero rows, and a write that landed reports as unmatched.
|
|
489
|
-
*
|
|
490
|
-
* 🔴 Inherits the adapter's MySQL caveat: MySQL counts CHANGED rows rather
|
|
491
|
-
* than matched ones, so a caller using this as a compare-and-set must write
|
|
492
|
-
* at least one column the update always moves — a state transition, a version
|
|
493
|
-
* bump, a timestamp of sufficient resolution. Postgres (`rowCount`) and
|
|
494
|
-
* SQLite (`changes`) count matched rows and do not need the precaution, which
|
|
495
|
-
* is exactly why it cannot be dropped: the dialect where the distinction
|
|
496
|
-
* exists is the one with no RETURNING to fall back on.
|
|
497
|
-
*
|
|
498
|
-
* @param table - Table name
|
|
499
|
-
* @param data - Column values to write
|
|
500
|
-
* @param where - Conditions the update must match
|
|
501
|
-
* @returns Number of rows the statement affected
|
|
502
|
-
*/
|
|
503
|
-
updateCount(table: string, data: Record<string, unknown>, where: WhereClause): Promise<number>;
|
|
504
|
-
/**
|
|
505
|
-
* Delete records.
|
|
506
|
-
*
|
|
507
|
-
* @param table - Table name
|
|
508
|
-
* @param where - Conditions for records to delete
|
|
509
|
-
* @param options - Delete options
|
|
510
|
-
* @returns Number of deleted records
|
|
511
|
-
*/
|
|
512
|
-
delete(table: string, where: WhereClause, options?: DeleteOptions): Promise<number>;
|
|
513
|
-
/**
|
|
514
|
-
* Upsert a record (INSERT or UPDATE).
|
|
515
|
-
*
|
|
516
|
-
* @param table - Table name
|
|
517
|
-
* @param data - Record data
|
|
518
|
-
* @param options - Upsert options (must specify conflict columns)
|
|
519
|
-
* @returns Upserted record (with RETURNING columns if specified)
|
|
520
|
-
*/
|
|
521
|
-
upsert<T = unknown>(table: string, data: Record<string, unknown>, options: UpsertOptions): Promise<T>;
|
|
522
|
-
/**
|
|
523
|
-
* Create a savepoint (PostgreSQL, SQLite only).
|
|
524
|
-
*
|
|
525
|
-
* @remarks
|
|
526
|
-
* Savepoints allow partial rollback within a transaction.
|
|
527
|
-
* Not supported on MySQL.
|
|
528
|
-
*
|
|
529
|
-
* @param name - Savepoint name
|
|
530
|
-
*/
|
|
531
|
-
savepoint?(name: string): Promise<void>;
|
|
532
|
-
/**
|
|
533
|
-
* Rollback to a savepoint (PostgreSQL, SQLite only).
|
|
534
|
-
*
|
|
535
|
-
* @remarks
|
|
536
|
-
* Discards all changes made after the savepoint was created.
|
|
537
|
-
*
|
|
538
|
-
* @param name - Savepoint name
|
|
539
|
-
*/
|
|
540
|
-
rollbackToSavepoint?(name: string): Promise<void>;
|
|
541
|
-
/**
|
|
542
|
-
* Release a savepoint (PostgreSQL, SQLite only).
|
|
543
|
-
*
|
|
544
|
-
* @remarks
|
|
545
|
-
* Commits the savepoint, making its changes permanent within the transaction.
|
|
546
|
-
*
|
|
547
|
-
* @param name - Savepoint name
|
|
548
|
-
*/
|
|
549
|
-
releaseSavepoint?(name: string): Promise<void>;
|
|
550
|
-
/**
|
|
551
|
-
* Return the Drizzle ORM instance bound to THIS transaction's connection.
|
|
552
|
-
*
|
|
553
|
-
* @remarks
|
|
554
|
-
* Runs Drizzle `sql` templates / fluent queries inside the caller's
|
|
555
|
-
* transaction (same client the delegated CRUD methods use), so services
|
|
556
|
-
* that drop to Drizzle raw SQL (e.g. junction-table writes) can participate
|
|
557
|
-
* in the transaction instead of running on the pooled connection. Required
|
|
558
|
-
* so callers never silently fall back to the pooled connection (which would
|
|
559
|
-
* run a write outside the transaction); every adapter must implement it.
|
|
560
|
-
* Generic return so callers narrow to the dialect Drizzle type they need
|
|
561
|
-
* without an `any` cast.
|
|
562
|
-
*/
|
|
563
|
-
getDrizzle<T = unknown>(): T;
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
/**
|
|
567
|
-
* Database capability type definitions.
|
|
568
|
-
*
|
|
569
|
-
* @packageDocumentation
|
|
570
|
-
*/
|
|
571
|
-
|
|
572
|
-
/**
|
|
573
|
-
* Database feature capabilities.
|
|
574
|
-
*
|
|
575
|
-
* @remarks
|
|
576
|
-
* Describes what features are supported by a specific database adapter.
|
|
577
|
-
* Services can check these capabilities to conditionally enable features
|
|
578
|
-
* or implement fallback behavior.
|
|
579
|
-
*
|
|
580
|
-
* @example
|
|
581
|
-
* ```typescript
|
|
582
|
-
* const capabilities = adapter.getCapabilities();
|
|
583
|
-
* if (capabilities.supportsJsonb) {
|
|
584
|
-
* // Use JSONB-specific features
|
|
585
|
-
* } else if (capabilities.supportsJson) {
|
|
586
|
-
* // Fallback to JSON
|
|
587
|
-
* }
|
|
588
|
-
* ```
|
|
589
|
-
*
|
|
590
|
-
* @public
|
|
591
|
-
*/
|
|
592
|
-
interface DatabaseCapabilities {
|
|
593
|
-
/** Database dialect */
|
|
594
|
-
dialect: SupportedDialect;
|
|
595
|
-
/**
|
|
596
|
-
* Native JSONB support (PostgreSQL only).
|
|
597
|
-
*
|
|
598
|
-
* @remarks
|
|
599
|
-
* JSONB provides better performance and indexing than JSON.
|
|
600
|
-
* Other databases will use JSON or emulated JSON.
|
|
601
|
-
*/
|
|
602
|
-
supportsJsonb: boolean;
|
|
603
|
-
/**
|
|
604
|
-
* JSON column type support.
|
|
605
|
-
*
|
|
606
|
-
* @remarks
|
|
607
|
-
* All supported databases have some form of JSON support:
|
|
608
|
-
* - PostgreSQL: Native JSON and JSONB
|
|
609
|
-
* - MySQL: Native JSON column type
|
|
610
|
-
* - SQLite: JSON functions (json_extract, json_array, etc.)
|
|
611
|
-
*/
|
|
612
|
-
supportsJson: boolean;
|
|
613
|
-
/**
|
|
614
|
-
* Array column type support (PostgreSQL only).
|
|
615
|
-
*
|
|
616
|
-
* @remarks
|
|
617
|
-
* PostgreSQL has native array types. Other databases must use
|
|
618
|
-
* JSON arrays or separate tables.
|
|
619
|
-
*/
|
|
620
|
-
supportsArrays: boolean;
|
|
621
|
-
/**
|
|
622
|
-
* Generated/computed columns support.
|
|
623
|
-
*
|
|
624
|
-
* @remarks
|
|
625
|
-
* Support for columns whose values are automatically computed from
|
|
626
|
-
* other columns:
|
|
627
|
-
* - PostgreSQL: GENERATED ALWAYS AS ... STORED
|
|
628
|
-
* - MySQL: Generated columns
|
|
629
|
-
* - SQLite: Generated columns (3.31.0+)
|
|
630
|
-
*/
|
|
631
|
-
supportsGeneratedColumns: boolean;
|
|
632
|
-
/**
|
|
633
|
-
* Full-text search support.
|
|
634
|
-
*
|
|
635
|
-
* @remarks
|
|
636
|
-
* Native full-text search capabilities:
|
|
637
|
-
* - PostgreSQL: tsvector/tsquery
|
|
638
|
-
* - MySQL: FULLTEXT indexes (limited)
|
|
639
|
-
* - SQLite: FTS5 extension (not enabled by default)
|
|
640
|
-
*/
|
|
641
|
-
supportsFts: boolean;
|
|
642
|
-
/**
|
|
643
|
-
* Case-insensitive ILIKE operator support (PostgreSQL only).
|
|
644
|
-
*
|
|
645
|
-
* @remarks
|
|
646
|
-
* Other databases must emulate with LOWER(column) LIKE LOWER(value).
|
|
647
|
-
*/
|
|
648
|
-
supportsIlike: boolean;
|
|
649
|
-
/**
|
|
650
|
-
* RETURNING clause support.
|
|
651
|
-
*
|
|
652
|
-
* @remarks
|
|
653
|
-
* Support for returning data from INSERT/UPDATE/DELETE:
|
|
654
|
-
* - PostgreSQL: Yes
|
|
655
|
-
* - MySQL: No (requires separate SELECT)
|
|
656
|
-
* - SQLite: Yes
|
|
657
|
-
*/
|
|
658
|
-
supportsReturning: boolean;
|
|
659
|
-
/**
|
|
660
|
-
* Savepoint support for nested transactions.
|
|
661
|
-
*
|
|
662
|
-
* @remarks
|
|
663
|
-
* - PostgreSQL: Yes
|
|
664
|
-
* - MySQL: No (limited support, not recommended)
|
|
665
|
-
* - SQLite: Yes
|
|
666
|
-
*/
|
|
667
|
-
supportsSavepoints: boolean;
|
|
668
|
-
/**
|
|
669
|
-
* ON CONFLICT clause support for upserts.
|
|
670
|
-
*
|
|
671
|
-
* @remarks
|
|
672
|
-
* - PostgreSQL: ON CONFLICT DO NOTHING/UPDATE
|
|
673
|
-
* - MySQL: ON DUPLICATE KEY UPDATE (different syntax)
|
|
674
|
-
* - SQLite: ON CONFLICT (similar to PostgreSQL)
|
|
675
|
-
*/
|
|
676
|
-
supportsOnConflict: boolean;
|
|
677
|
-
/**
|
|
678
|
-
* Maximum number of parameters per query.
|
|
679
|
-
*
|
|
680
|
-
* @remarks
|
|
681
|
-
* Database-specific limits:
|
|
682
|
-
* - PostgreSQL: 65,535
|
|
683
|
-
* - MySQL: 65,535
|
|
684
|
-
* - SQLite: 999 (can be increased with SQLITE_MAX_VARIABLE_NUMBER)
|
|
685
|
-
*/
|
|
686
|
-
maxParamsPerQuery: number;
|
|
687
|
-
/**
|
|
688
|
-
* Maximum length for table/column identifiers.
|
|
689
|
-
*
|
|
690
|
-
* @remarks
|
|
691
|
-
* - PostgreSQL: 63 bytes
|
|
692
|
-
* - MySQL: 64 characters
|
|
693
|
-
* - SQLite: No limit (practically unlimited)
|
|
694
|
-
*/
|
|
695
|
-
maxIdentifierLength: number;
|
|
696
|
-
/**
|
|
697
|
-
* Whether the server accepts `SELECT ... FOR SHARE`.
|
|
698
|
-
*
|
|
699
|
-
* @remarks
|
|
700
|
-
* Reported by the MySQL adapter once it has connected and read the server's
|
|
701
|
-
* version: MySQL 8, Aurora MySQL and Vitess/PlanetScale accept it, MariaDB
|
|
702
|
-
* and TiDB reject it as a syntax error. PostgreSQL always accepts it and
|
|
703
|
-
* SQLite has no row locks, so their adapters leave it unset. Unset means
|
|
704
|
-
* not known; a caller then takes a lock every server accepts.
|
|
705
|
-
*
|
|
706
|
-
* @experimental
|
|
707
|
-
*/
|
|
708
|
-
sharedRowLock?: boolean;
|
|
709
|
-
}
|
|
710
|
-
/**
|
|
711
|
-
* Connection pool statistics.
|
|
712
|
-
*
|
|
713
|
-
* @remarks
|
|
714
|
-
* Provides visibility into connection pool health. Not all adapters
|
|
715
|
-
* provide pool statistics (e.g., SQLite is single-connection).
|
|
716
|
-
*
|
|
717
|
-
* @public
|
|
718
|
-
*/
|
|
719
|
-
interface PoolStats {
|
|
720
|
-
/** Total number of connections in the pool */
|
|
721
|
-
total: number;
|
|
722
|
-
/** Number of idle (available) connections */
|
|
723
|
-
idle: number;
|
|
724
|
-
/** Number of clients waiting for a connection */
|
|
725
|
-
waiting: number;
|
|
726
|
-
/** Number of connections currently in use */
|
|
727
|
-
active: number;
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
/**
|
|
731
|
-
* Database migration type definitions.
|
|
732
|
-
*
|
|
733
|
-
* @packageDocumentation
|
|
734
|
-
*/
|
|
735
|
-
|
|
736
|
-
/**
|
|
737
|
-
* Migration definition.
|
|
738
|
-
*
|
|
739
|
-
* @remarks
|
|
740
|
-
* Represents a single database migration with up and optional down functions.
|
|
741
|
-
* Migrations can be defined as raw SQL strings or as functions that use the
|
|
742
|
-
* transaction context for more complex operations.
|
|
743
|
-
*
|
|
744
|
-
* @public
|
|
745
|
-
*/
|
|
746
|
-
interface Migration {
|
|
747
|
-
/** Unique migration identifier (e.g., "20250104_001_create_users") */
|
|
748
|
-
id: string;
|
|
749
|
-
/** Human-readable migration name */
|
|
750
|
-
name: string;
|
|
751
|
-
/** Unix timestamp when migration was created */
|
|
752
|
-
timestamp: number;
|
|
753
|
-
/** Forward migration (apply changes) */
|
|
754
|
-
up: string | ((tx: TransactionContext) => Promise<void>);
|
|
755
|
-
/** Reverse migration (undo changes) - optional */
|
|
756
|
-
down?: string | ((tx: TransactionContext) => Promise<void>);
|
|
757
|
-
}
|
|
758
|
-
/**
|
|
759
|
-
* Migration record stored in the database.
|
|
760
|
-
*
|
|
761
|
-
* @remarks
|
|
762
|
-
* Tracks which migrations have been applied to the database.
|
|
763
|
-
* The migrations table is automatically created by the adapter.
|
|
764
|
-
*
|
|
765
|
-
* @public
|
|
766
|
-
*/
|
|
767
|
-
interface MigrationRecord {
|
|
768
|
-
/** Migration identifier */
|
|
769
|
-
id: string;
|
|
770
|
-
/** Migration name */
|
|
771
|
-
name: string;
|
|
772
|
-
/** When the migration was applied */
|
|
773
|
-
appliedAt: Date;
|
|
774
|
-
/** Optional checksum to detect migration changes */
|
|
775
|
-
checksum?: string;
|
|
776
|
-
}
|
|
777
|
-
/**
|
|
778
|
-
* Migration execution result.
|
|
779
|
-
*
|
|
780
|
-
* @remarks
|
|
781
|
-
* Provides information about migration status including applied and
|
|
782
|
-
* pending migrations.
|
|
783
|
-
*
|
|
784
|
-
* @public
|
|
785
|
-
*/
|
|
786
|
-
interface MigrationResult {
|
|
787
|
-
/** Migrations that were applied in this execution */
|
|
788
|
-
applied: MigrationRecord[];
|
|
789
|
-
/** Migrations that are pending (not yet applied) */
|
|
790
|
-
pending: Migration[];
|
|
791
|
-
/** ID of the current (most recent) migration, or null if none applied */
|
|
792
|
-
current: string | null;
|
|
793
|
-
}
|
|
794
|
-
/**
|
|
795
|
-
* Options for migration execution.
|
|
796
|
-
*
|
|
797
|
-
* @public
|
|
798
|
-
*/
|
|
799
|
-
interface MigrationOptions {
|
|
800
|
-
/** Target migration to migrate to (default: latest) */
|
|
801
|
-
target?: string;
|
|
802
|
-
/** Dry run mode - don't actually apply migrations */
|
|
803
|
-
dryRun?: boolean;
|
|
804
|
-
/** Run migrations in a single transaction (default: true) */
|
|
805
|
-
useTransaction?: boolean;
|
|
806
|
-
/**
|
|
807
|
-
* Strict checksum validation (default: true).
|
|
808
|
-
* If true, modified migrations will cause an error.
|
|
809
|
-
* If false, modified migrations will generate a warning.
|
|
810
|
-
*/
|
|
811
|
-
strictChecksums?: boolean;
|
|
812
|
-
}
|
|
813
|
-
/**
|
|
814
|
-
* Migration status information.
|
|
815
|
-
*
|
|
816
|
-
* @public
|
|
817
|
-
*/
|
|
818
|
-
interface MigrationStatus {
|
|
819
|
-
/** Current migration ID (most recently applied) */
|
|
820
|
-
current: string | null;
|
|
821
|
-
/** Total number of applied migrations */
|
|
822
|
-
appliedCount: number;
|
|
823
|
-
/** Total number of pending migrations */
|
|
824
|
-
pendingCount: number;
|
|
825
|
-
/** Applied migration records */
|
|
826
|
-
applied: MigrationRecord[];
|
|
827
|
-
/** Pending migrations */
|
|
828
|
-
pending: Migration[];
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
export { type CountOptions as C, type DeleteOptions as D, type InsertOptions as I, type JoinSpec as J, type MigrationRecord as M, type OrderBySpec as O, type PoolStats as P, type SelectOptions as S, type TransactionContext as T, type UpsertOptions as U, type WhereClause as W, type Migration as a, type MigrationStatus as b, type MigrationOptions as c, type MigrationResult as d, type TransactionOptions as e, type DatabaseCapabilities as f, type UpdateOptions as g, type TransactionIsolationLevel as h, WHERE_OPERATORS as i, type WhereCondition as j, type WhereOperator as k };
|