@aiao/rxdb-adapter-sqlite 0.0.1
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 +1 -0
- package/RxDBAdapterSqlite.d.ts +66 -0
- package/SqliteClient.d.ts +19 -0
- package/SqliteRepository.d.ts +23 -0
- package/SqliteRepositoryBase.d.ts +85 -0
- package/SqliteTreeRepository.d.ts +17 -0
- package/execute_statement_helper.d.ts +7 -0
- package/generate_entity_delete_sql.d.ts +9 -0
- package/generate_entity_find_tree_sql.d.ts +41 -0
- package/generate_entity_insert_sql.d.ts +9 -0
- package/generate_entity_soft_delete_sql.d.ts +9 -0
- package/generate_entity_update_sql.d.ts +9 -0
- package/generate_query_find_sql.d.ts +30 -0
- package/generate_table_create_sql.d.ts +8 -0
- package/generate_table_trigger_sql.d.ts +8 -0
- package/index.d.ts +5 -0
- package/index.js +1136 -0
- package/package.json +20 -0
- package/sqlite-load.utils.d.ts +39 -0
- package/sqlite.interface.d.ts +57 -0
- package/sqlite.utils.d.ts +107 -0
- package/types.d.ts +7 -0
- package/wa-sqlite.d.ts +611 -0
package/wa-sqlite.d.ts
ADDED
|
@@ -0,0 +1,611 @@
|
|
|
1
|
+
export type SQLiteCompatibleType = number | string | Uint8Array | Array<number> | bigint | null;
|
|
2
|
+
interface SQLitePrepareOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Statement handles prepared and yielded by {@link SQLiteAPI.statements}
|
|
5
|
+
* are normally valid only within the scope of an iteration.
|
|
6
|
+
* Set `unscoped` to `true` to give iterated statements an arbitrary
|
|
7
|
+
* lifetime.
|
|
8
|
+
*/
|
|
9
|
+
unscoped?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* SQLITE_PREPARE_* flags
|
|
12
|
+
* @see https://www.sqlite.org/c3ref/c_prepare_normalize.html#sqlitepreparepersistent
|
|
13
|
+
*/
|
|
14
|
+
flags?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface SQLiteAPI {
|
|
17
|
+
/**
|
|
18
|
+
* Bind a collection of values to a statement
|
|
19
|
+
*
|
|
20
|
+
* This convenience function binds values from either an array or object
|
|
21
|
+
* to a prepared statement with placeholder parameters.
|
|
22
|
+
*
|
|
23
|
+
* Array example using numbered parameters (numbering is implicit in
|
|
24
|
+
* this example):
|
|
25
|
+
* ```
|
|
26
|
+
* const sql = 'INSERT INTO tbl VALUES (?, ?, ?)';
|
|
27
|
+
* for await (const stmt of sqlite3.statements(db, sql) {
|
|
28
|
+
* sqlite3.bind_collection(stmt, [42, 'hello', null]);
|
|
29
|
+
* ...
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* Object example using named parameters (':', '@', or '$' prefixes
|
|
34
|
+
* are allowed):
|
|
35
|
+
* ```
|
|
36
|
+
* const sql = 'INSERT INTO tbl VALUES (?, ?, ?)';
|
|
37
|
+
* for await (const stmt of sqlite3.statements(db, sql) {
|
|
38
|
+
* sqlite3.bind_collection(stmt, {
|
|
39
|
+
* '@foo': 42,
|
|
40
|
+
* '@bar': 'hello',
|
|
41
|
+
* '@baz': null,
|
|
42
|
+
* });
|
|
43
|
+
* ...
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* Note that SQLite bindings are indexed beginning with 1, but when
|
|
48
|
+
* binding values from an array `a` the values begin with `a[0]`.
|
|
49
|
+
* @param stmt prepared statement pointer
|
|
50
|
+
* @param bindings
|
|
51
|
+
* @returns `SQLITE_OK` (throws exception on error)
|
|
52
|
+
*/
|
|
53
|
+
bind_collection(stmt: number, bindings: {
|
|
54
|
+
[index: string]: SQLiteCompatibleType | null;
|
|
55
|
+
} | Array<SQLiteCompatibleType | null>): number;
|
|
56
|
+
/**
|
|
57
|
+
* Bind value to prepared statement
|
|
58
|
+
*
|
|
59
|
+
* This convenience function calls the appropriate `bind_*` function
|
|
60
|
+
* based on the type of `value`. Note that binding indices begin with 1.
|
|
61
|
+
* @param stmt prepared statement pointer
|
|
62
|
+
* @param i binding index
|
|
63
|
+
* @param value
|
|
64
|
+
* @returns `SQLITE_OK` (throws exception on error)
|
|
65
|
+
*/
|
|
66
|
+
bind(stmt: number, i: number, value: SQLiteCompatibleType | null): number;
|
|
67
|
+
/**
|
|
68
|
+
* Bind blob to prepared statement parameter
|
|
69
|
+
*
|
|
70
|
+
* Note that binding indices begin with 1.
|
|
71
|
+
* @see https://www.sqlite.org/c3ref/bind_blob.html
|
|
72
|
+
* @param stmt prepared statement pointer
|
|
73
|
+
* @param i binding index
|
|
74
|
+
* @param value
|
|
75
|
+
* @returns `SQLITE_OK` (throws exception on error)
|
|
76
|
+
*/
|
|
77
|
+
bind_blob(stmt: number, i: number, value: Uint8Array | Array<number>): number;
|
|
78
|
+
/**
|
|
79
|
+
* Bind number to prepared statement parameter
|
|
80
|
+
*
|
|
81
|
+
* Note that binding indices begin with 1.
|
|
82
|
+
* @see https://www.sqlite.org/c3ref/bind_blob.html
|
|
83
|
+
* @param stmt prepared statement pointer
|
|
84
|
+
* @param i binding index
|
|
85
|
+
* @param value
|
|
86
|
+
* @returns `SQLITE_OK` (throws exception on error)
|
|
87
|
+
*/
|
|
88
|
+
bind_double(stmt: number, i: number, value: number): number;
|
|
89
|
+
/**
|
|
90
|
+
* Bind number to prepared statement parameter
|
|
91
|
+
*
|
|
92
|
+
* Note that binding indices begin with 1.
|
|
93
|
+
* @see https://www.sqlite.org/c3ref/bind_blob.html
|
|
94
|
+
* @param stmt prepared statement pointer
|
|
95
|
+
* @param i binding index
|
|
96
|
+
* @param value
|
|
97
|
+
* @returns `SQLITE_OK` (throws exception on error)
|
|
98
|
+
*/
|
|
99
|
+
bind_int(stmt: number, i: number, value: number): number;
|
|
100
|
+
/**
|
|
101
|
+
* Bind number to prepared statement parameter
|
|
102
|
+
*
|
|
103
|
+
* Note that binding indices begin with 1.
|
|
104
|
+
* @see https://www.sqlite.org/c3ref/bind_blob.html
|
|
105
|
+
* @param stmt prepared statement pointer
|
|
106
|
+
* @param i binding index
|
|
107
|
+
* @param value
|
|
108
|
+
* @returns `SQLITE_OK` (throws exception on error)
|
|
109
|
+
*/
|
|
110
|
+
bind_int64(stmt: number, i: number, value: bigint): number;
|
|
111
|
+
/**
|
|
112
|
+
* Bind null to prepared statement
|
|
113
|
+
*
|
|
114
|
+
* Note that binding indices begin with 1.
|
|
115
|
+
* @see https://www.sqlite.org/c3ref/bind_blob.html
|
|
116
|
+
* @param stmt prepared statement pointer
|
|
117
|
+
* @param i binding index
|
|
118
|
+
* @returns `SQLITE_OK` (throws exception on error)
|
|
119
|
+
*/
|
|
120
|
+
bind_null(stmt: number, i: number): number;
|
|
121
|
+
/**
|
|
122
|
+
* Get number of bound parameters
|
|
123
|
+
* @see https://www.sqlite.org/c3ref/bind_parameter_count.html
|
|
124
|
+
* @param stmt prepared statement pointer
|
|
125
|
+
* @returns number of statement binding locations
|
|
126
|
+
*/
|
|
127
|
+
bind_parameter_count(stmt: number): number;
|
|
128
|
+
/**
|
|
129
|
+
* Get name of bound parameter
|
|
130
|
+
*
|
|
131
|
+
* Note that binding indices begin with 1.
|
|
132
|
+
* @see https://www.sqlite.org/c3ref/bind_parameter_name.html
|
|
133
|
+
* @param stmt prepared statement pointer
|
|
134
|
+
* @param i binding index
|
|
135
|
+
* @returns binding name
|
|
136
|
+
*/
|
|
137
|
+
bind_parameter_name(stmt: number, i: number): string;
|
|
138
|
+
/**
|
|
139
|
+
* Bind string to prepared statement
|
|
140
|
+
*
|
|
141
|
+
* Note that binding indices begin with 1.
|
|
142
|
+
* @see https://www.sqlite.org/c3ref/bind_blob.html
|
|
143
|
+
* @param stmt prepared statement pointer
|
|
144
|
+
* @param i binding index
|
|
145
|
+
* @param value
|
|
146
|
+
* @returns `SQLITE_OK` (throws exception on error)
|
|
147
|
+
*/
|
|
148
|
+
bind_text(stmt: number, i: number, value: string): number;
|
|
149
|
+
/**
|
|
150
|
+
* Get count of rows modified by last insert/update
|
|
151
|
+
* @see https://www.sqlite.org/c3ref/changes.html
|
|
152
|
+
* @param db database pointer
|
|
153
|
+
* @returns number of rows modified
|
|
154
|
+
*/
|
|
155
|
+
changes(db: number): number;
|
|
156
|
+
/**
|
|
157
|
+
* Reset all bindings on a prepared statement.
|
|
158
|
+
* @see https://www.sqlite.org/c3ref/clear_bindings.html
|
|
159
|
+
* @param stmt prepared statement pointer
|
|
160
|
+
* @returns `SQLITE_OK` (throws exception on error)
|
|
161
|
+
*/
|
|
162
|
+
clear_bindings(stmt: number): number;
|
|
163
|
+
/**
|
|
164
|
+
* Get the last insert id
|
|
165
|
+
* @see https://www.sqlite.org/c3ref/changes.html
|
|
166
|
+
* @param db database pointer
|
|
167
|
+
* @returns last insert id
|
|
168
|
+
*/
|
|
169
|
+
last_insert_id(db: number): number;
|
|
170
|
+
/**
|
|
171
|
+
* Close database connection
|
|
172
|
+
* @see https://www.sqlite.org/c3ref/close.html
|
|
173
|
+
* @param db database pointer
|
|
174
|
+
* @returns `SQLITE_OK` (throws exception on error)
|
|
175
|
+
*/
|
|
176
|
+
close(db: number): Promise<number>;
|
|
177
|
+
/**
|
|
178
|
+
* Call the appropriate `column_*` function based on the column type
|
|
179
|
+
*
|
|
180
|
+
* The type is determined by calling {@link column_type}, which may
|
|
181
|
+
* not match the type declared in `CREATE TABLE`. Note that if the column
|
|
182
|
+
* value is a blob then as with `column_blob` the result may be invalid
|
|
183
|
+
* after the next SQLite call; copy if it needs to be retained.
|
|
184
|
+
*
|
|
185
|
+
* Integer values are returned as Number if within the min/max safe
|
|
186
|
+
* integer bounds, otherwise they are returned as BigInt.
|
|
187
|
+
* @param stmt prepared statement pointer
|
|
188
|
+
* @param i column index
|
|
189
|
+
* @returns column value
|
|
190
|
+
*/
|
|
191
|
+
column(stmt: number, i: number): SQLiteCompatibleType;
|
|
192
|
+
/**
|
|
193
|
+
* Extract a column value from a row after a prepared statment {@link step}
|
|
194
|
+
*
|
|
195
|
+
* The contents of the returned buffer may be invalid after the
|
|
196
|
+
* next SQLite call. Make a copy of the data (e.g. with `.slice()`)
|
|
197
|
+
* if longer retention is required.
|
|
198
|
+
* @see https://www.sqlite.org/c3ref/column_blob.html
|
|
199
|
+
* @param stmt prepared statement pointer
|
|
200
|
+
* @param i column index
|
|
201
|
+
* @returns column value
|
|
202
|
+
*/
|
|
203
|
+
column_blob(stmt: number, i: number): Uint8Array;
|
|
204
|
+
/**
|
|
205
|
+
* Get storage size for column text or blob
|
|
206
|
+
* @see https://www.sqlite.org/c3ref/column_blob.html
|
|
207
|
+
* @param stmt prepared statement pointer
|
|
208
|
+
* @param i column index
|
|
209
|
+
* @returns number of bytes in column text or blob
|
|
210
|
+
*/
|
|
211
|
+
column_bytes(stmt: number, i: number): number;
|
|
212
|
+
/**
|
|
213
|
+
* Get number of columns for a prepared statement
|
|
214
|
+
* @see https://www.sqlite.org/c3ref/column_blob.html
|
|
215
|
+
* @param stmt prepared statement pointer
|
|
216
|
+
* @returns number of columns
|
|
217
|
+
*/
|
|
218
|
+
column_count(stmt: number): number;
|
|
219
|
+
/**
|
|
220
|
+
* Extract a column value from a row after a prepared statment {@link step}
|
|
221
|
+
* @see https://www.sqlite.org/c3ref/column_blob.html
|
|
222
|
+
* @param stmt prepared statement pointer
|
|
223
|
+
* @param i column index
|
|
224
|
+
* @returns column value
|
|
225
|
+
*/
|
|
226
|
+
column_double(stmt: number, i: number): number;
|
|
227
|
+
/**
|
|
228
|
+
* Extract a column value from a row after a prepared statment {@link step}
|
|
229
|
+
* @see https://www.sqlite.org/c3ref/column_blob.html
|
|
230
|
+
* @param stmt prepared statement pointer
|
|
231
|
+
* @param i column index
|
|
232
|
+
* @returns column value
|
|
233
|
+
*/
|
|
234
|
+
column_int(stmt: number, i: number): number;
|
|
235
|
+
/**
|
|
236
|
+
* Extract a column value from a row after a prepared statment {@link step}
|
|
237
|
+
* @see https://www.sqlite.org/c3ref/column_blob.html
|
|
238
|
+
* @param stmt prepared statement pointer
|
|
239
|
+
* @param i column index
|
|
240
|
+
* @returns column value
|
|
241
|
+
*/
|
|
242
|
+
column_int64(stmt: number, i: number): bigint;
|
|
243
|
+
/**
|
|
244
|
+
* Get a column name for a prepared statement
|
|
245
|
+
* @see https://www.sqlite.org/c3ref/column_blob.html
|
|
246
|
+
* @param stmt prepared statement pointer
|
|
247
|
+
* @param i column index
|
|
248
|
+
* @returns column name
|
|
249
|
+
*/
|
|
250
|
+
column_name(stmt: number, i: number): string;
|
|
251
|
+
/**
|
|
252
|
+
* Get names for all columns of a prepared statement
|
|
253
|
+
*
|
|
254
|
+
* This is a convenience function that calls {@link column_count} and
|
|
255
|
+
* {@link column_name}.
|
|
256
|
+
* @param stmt
|
|
257
|
+
* @returns array of column names
|
|
258
|
+
*/
|
|
259
|
+
column_names(stmt: number): Array<string>;
|
|
260
|
+
/**
|
|
261
|
+
* Extract a column value from a row after a prepared statment {@link step}
|
|
262
|
+
* @see https://www.sqlite.org/c3ref/column_blob.html
|
|
263
|
+
* @param stmt prepared statement pointer
|
|
264
|
+
* @param i column index
|
|
265
|
+
* @returns column value
|
|
266
|
+
*/
|
|
267
|
+
column_text(stmt: number, i: number): string;
|
|
268
|
+
/**
|
|
269
|
+
* Get column type for a prepared statement
|
|
270
|
+
*
|
|
271
|
+
* Note that this type may not match the type declared in `CREATE TABLE`.
|
|
272
|
+
* @see https://www.sqlite.org/c3ref/column_blob.html
|
|
273
|
+
* @param stmt prepared statement pointer
|
|
274
|
+
* @param i column index
|
|
275
|
+
* @returns enumeration value for type
|
|
276
|
+
*/
|
|
277
|
+
column_type(stmt: number, i: number): number;
|
|
278
|
+
/**
|
|
279
|
+
* Register a commit hook
|
|
280
|
+
*
|
|
281
|
+
* @see https://www.sqlite.org/c3ref/commit_hook.html
|
|
282
|
+
*
|
|
283
|
+
* @param db database pointer
|
|
284
|
+
* @param callback If a non-zero value is returned, commit is converted into
|
|
285
|
+
* a rollback; disables callback when null
|
|
286
|
+
*/
|
|
287
|
+
commit_hook(db: number, callback: (() => number) | null): void;
|
|
288
|
+
/**
|
|
289
|
+
* Create or redefine SQL functions
|
|
290
|
+
*
|
|
291
|
+
* The application data passed is ignored. Use closures instead.
|
|
292
|
+
*
|
|
293
|
+
* If any callback function returns a Promise, that function must
|
|
294
|
+
* be declared `async`, i.e. it must allow use of `await`.
|
|
295
|
+
* @see https://sqlite.org/c3ref/create_function.html
|
|
296
|
+
* @param db database pointer
|
|
297
|
+
* @param zFunctionName
|
|
298
|
+
* @param nArg number of function arguments
|
|
299
|
+
* @param eTextRep text encoding (and other flags)
|
|
300
|
+
* @param pApp application data (ignored)
|
|
301
|
+
* @param xFunc
|
|
302
|
+
* @param xStep
|
|
303
|
+
* @param xFinal
|
|
304
|
+
* @returns `SQLITE_OK` (throws exception on error)
|
|
305
|
+
*/
|
|
306
|
+
create_function(db: number, zFunctionName: string, nArg: number, eTextRep: number, pApp: number, xFunc?: (context: number, values: Uint32Array) => void | Promise<void>, xStep?: (context: number, values: Uint32Array) => void | Promise<void>, xFinal?: (context: number) => void | Promise<void>): number;
|
|
307
|
+
/**
|
|
308
|
+
* Get number of columns in current row of a prepared statement
|
|
309
|
+
* @see https://www.sqlite.org/c3ref/data_count.html
|
|
310
|
+
* @param stmt prepared statement pointer
|
|
311
|
+
* @returns number of columns
|
|
312
|
+
*/
|
|
313
|
+
data_count(stmt: number): number;
|
|
314
|
+
/**
|
|
315
|
+
* One-step query execution interface
|
|
316
|
+
*
|
|
317
|
+
* The implementation of this function uses {@link row}, which makes a
|
|
318
|
+
* copy of blobs and returns BigInt for integers outside the safe integer
|
|
319
|
+
* bounds for Number.
|
|
320
|
+
* @see https://www.sqlite.org/c3ref/exec.html
|
|
321
|
+
* @param db database pointer
|
|
322
|
+
* @param zSQL queries
|
|
323
|
+
* @param callback called for each output row
|
|
324
|
+
* @returns Promise resolving to `SQLITE_OK` (rejects on error)
|
|
325
|
+
*/
|
|
326
|
+
exec(db: number, zSQL: string, callback?: (row: Array<SQLiteCompatibleType | null>, columns: string[]) => void): Promise<number>;
|
|
327
|
+
/**
|
|
328
|
+
* Destroy a prepared statement object compiled by {@link statements}
|
|
329
|
+
* with the `unscoped` option set to `true`
|
|
330
|
+
*
|
|
331
|
+
* This function does *not* throw on error.
|
|
332
|
+
* @see https://www.sqlite.org/c3ref/finalize.html
|
|
333
|
+
* @param stmt prepared statement pointer
|
|
334
|
+
* @returns Promise resolving to `SQLITE_OK` or error status
|
|
335
|
+
*/
|
|
336
|
+
finalize(stmt: number): Promise<number>;
|
|
337
|
+
/**
|
|
338
|
+
* Test for autocommit mode
|
|
339
|
+
* @see https://sqlite.org/c3ref/get_autocommit.html
|
|
340
|
+
* @param db database pointer
|
|
341
|
+
* @returns Non-zero if autocommit mode is on, zero otherwise
|
|
342
|
+
*/
|
|
343
|
+
get_autocommit(db: number): number;
|
|
344
|
+
/**
|
|
345
|
+
* Get SQLite library version
|
|
346
|
+
* @see https://www.sqlite.org/c3ref/libversion.html
|
|
347
|
+
* @returns version string, e.g. '3.35.5'
|
|
348
|
+
*/
|
|
349
|
+
libversion(): string;
|
|
350
|
+
/**
|
|
351
|
+
* Get SQLite library version
|
|
352
|
+
* @see https://www.sqlite.org/c3ref/libversion.html
|
|
353
|
+
* @returns version number, e.g. 3035005
|
|
354
|
+
*/
|
|
355
|
+
libversion_number(): number;
|
|
356
|
+
/**
|
|
357
|
+
* Set a usage limit on a connection.
|
|
358
|
+
* @see https://www.sqlite.org/c3ref/limit.html
|
|
359
|
+
* @param db database pointer
|
|
360
|
+
* @param id limit category
|
|
361
|
+
* @param newVal
|
|
362
|
+
* @returns previous setting
|
|
363
|
+
*/
|
|
364
|
+
limit(db: number, id: number, newVal: number): number;
|
|
365
|
+
/**
|
|
366
|
+
* Opening a new database connection.
|
|
367
|
+
*
|
|
368
|
+
* Note that this function differs from the C API in that it
|
|
369
|
+
* returns the Promise-wrapped database pointer (instead of a
|
|
370
|
+
* result code).
|
|
371
|
+
* @see https://sqlite.org/c3ref/open.html
|
|
372
|
+
* @param zFilename
|
|
373
|
+
* @param iFlags `SQLite.SQLITE_OPEN_CREATE | SQLite.SQLITE_OPEN_READWRITE` (0x6) if omitted
|
|
374
|
+
* @param zVfs VFS name
|
|
375
|
+
* @returns Promise-wrapped database pointer.
|
|
376
|
+
*/
|
|
377
|
+
open_v2(zFilename: string, iFlags?: number, zVfs?: string): Promise<number>;
|
|
378
|
+
/**
|
|
379
|
+
* Specify callback to be invoked between long-running queries
|
|
380
|
+
*
|
|
381
|
+
* The application data passed is ignored. Use closures instead.
|
|
382
|
+
*
|
|
383
|
+
* If any callback function returns a Promise, that function must
|
|
384
|
+
* be declared `async`, i.e. it must allow use of `await`.
|
|
385
|
+
* @param db database pointer
|
|
386
|
+
* @param nProgressOps target number of database operations between handler invocations
|
|
387
|
+
* @param handler
|
|
388
|
+
* @param userData
|
|
389
|
+
*/
|
|
390
|
+
progress_handler(db: number, nProgressOps: number, handler: (userData: any) => number | Promise<number>, userData: any): void;
|
|
391
|
+
/**
|
|
392
|
+
* Reset a prepared statement object
|
|
393
|
+
* @see https://www.sqlite.org/c3ref/reset.html
|
|
394
|
+
* @param stmt prepared statement pointer
|
|
395
|
+
* @returns Promise-wrapped `SQLITE_OK` (rejects on error)
|
|
396
|
+
*/
|
|
397
|
+
reset(stmt: number): Promise<number>;
|
|
398
|
+
/**
|
|
399
|
+
* Convenience function to call `result_*` based of the type of `value`
|
|
400
|
+
* @param context context pointer
|
|
401
|
+
* @param value
|
|
402
|
+
*/
|
|
403
|
+
result(context: number, value: (SQLiteCompatibleType | number[]) | null): void;
|
|
404
|
+
/**
|
|
405
|
+
* Set the result of a function or vtable column
|
|
406
|
+
* @see https://sqlite.org/c3ref/result_blob.html
|
|
407
|
+
* @param context context pointer
|
|
408
|
+
* @param value
|
|
409
|
+
*/
|
|
410
|
+
result_blob(context: number, value: Uint8Array | number[]): void;
|
|
411
|
+
/**
|
|
412
|
+
* Set the result of a function or vtable column
|
|
413
|
+
* @see https://sqlite.org/c3ref/result_blob.html
|
|
414
|
+
* @param context context pointer
|
|
415
|
+
* @param value
|
|
416
|
+
*/
|
|
417
|
+
result_double(context: number, value: number): void;
|
|
418
|
+
/**
|
|
419
|
+
* Set the result of a function or vtable column
|
|
420
|
+
* @see https://sqlite.org/c3ref/result_blob.html
|
|
421
|
+
* @param context context pointer
|
|
422
|
+
* @param value
|
|
423
|
+
*/
|
|
424
|
+
result_int(context: number, value: number): void;
|
|
425
|
+
/**
|
|
426
|
+
* Set the result of a function or vtable column
|
|
427
|
+
* @see https://sqlite.org/c3ref/result_blob.html
|
|
428
|
+
* @param context context pointer
|
|
429
|
+
* @param value
|
|
430
|
+
*/
|
|
431
|
+
result_int64(context: number, value: bigint): void;
|
|
432
|
+
/**
|
|
433
|
+
* Set the result of a function or vtable column
|
|
434
|
+
* @see https://sqlite.org/c3ref/result_blob.html
|
|
435
|
+
* @param context context pointer
|
|
436
|
+
*/
|
|
437
|
+
result_null(context: number): void;
|
|
438
|
+
/**
|
|
439
|
+
* Set the result of a function or vtable column
|
|
440
|
+
* @see https://sqlite.org/c3ref/result_blob.html
|
|
441
|
+
* @param context context pointer
|
|
442
|
+
* @param value
|
|
443
|
+
*/
|
|
444
|
+
result_text(context: number, value: string): void;
|
|
445
|
+
/**
|
|
446
|
+
* Get all column data for a row from a prepared statement step
|
|
447
|
+
*
|
|
448
|
+
* This convenience function will return a copy of any blob, unlike
|
|
449
|
+
* {@link column_blob} which returns a value referencing volatile WASM
|
|
450
|
+
* memory with short validity. Like {@link column}, it will return a
|
|
451
|
+
* BigInt for integers outside the safe integer bounds for Number.
|
|
452
|
+
* @param stmt prepared statement pointer
|
|
453
|
+
* @returns row data
|
|
454
|
+
*/
|
|
455
|
+
row(stmt: number): Array<SQLiteCompatibleType | null>;
|
|
456
|
+
/**
|
|
457
|
+
* Register a callback function that is invoked to authorize certain SQL statement actions.
|
|
458
|
+
* @see https://www.sqlite.org/c3ref/set_authorizer.html
|
|
459
|
+
* @param db database pointer
|
|
460
|
+
* @param authFunction
|
|
461
|
+
* @param userData
|
|
462
|
+
*/
|
|
463
|
+
set_authorizer(db: number, authFunction: (userData: any, iActionCode: number, param3: string | null, param4: string | null, param5: string | null, param6: string | null) => number | Promise<number>, userData: any): number;
|
|
464
|
+
/**
|
|
465
|
+
* Get statement SQL
|
|
466
|
+
* @see https://www.sqlite.org/c3ref/expanded_sql.html
|
|
467
|
+
* @param stmt prepared statement pointer
|
|
468
|
+
* @returns SQL
|
|
469
|
+
*/
|
|
470
|
+
sql(stmt: number): string;
|
|
471
|
+
/**
|
|
472
|
+
* SQL statement iterator
|
|
473
|
+
*
|
|
474
|
+
* This function manages statement compilation by creating an async
|
|
475
|
+
* iterator that yields a prepared statement handle on each iteration.
|
|
476
|
+
* It is typically used with a `for await` loop (in an async function),
|
|
477
|
+
* like this:
|
|
478
|
+
* ```javascript
|
|
479
|
+
* // Compile one statement on each iteration of this loop.
|
|
480
|
+
* for await (const stmt of sqlite3.statements(db, sql)) {
|
|
481
|
+
* // Bind parameters here if using SQLite placeholders.
|
|
482
|
+
*
|
|
483
|
+
* // Execute the statement with this loop.
|
|
484
|
+
* while (await sqlite3.step(stmt) === SQLite.SQLITE_ROW) {
|
|
485
|
+
* // Collect row data here.
|
|
486
|
+
* }
|
|
487
|
+
*
|
|
488
|
+
* // Change bindings, reset, and execute again if desired.
|
|
489
|
+
* }
|
|
490
|
+
* ```
|
|
491
|
+
*
|
|
492
|
+
* By default, the lifetime of a yielded prepared statement is managed
|
|
493
|
+
* automatically by the iterator, ending at the end of each iteration.
|
|
494
|
+
* {@link finalize} should *not* be called on a statement provided by
|
|
495
|
+
* the iterator unless the `unscoped` option is set to `true` (that
|
|
496
|
+
* option is provided for applications that wish to manage statement
|
|
497
|
+
* lifetimes manually).
|
|
498
|
+
*
|
|
499
|
+
* If using the iterator manually, i.e. by calling its `next`
|
|
500
|
+
* method, be sure to call the `return` method if iteration
|
|
501
|
+
* is abandoned before completion (`for await` and other implicit
|
|
502
|
+
* traversals provided by Javascript do this automatically)
|
|
503
|
+
* to ensure that all allocated resources are released.
|
|
504
|
+
* @see https://www.sqlite.org/c3ref/prepare.html
|
|
505
|
+
* @param db database pointer
|
|
506
|
+
* @param sql
|
|
507
|
+
* @param options
|
|
508
|
+
*/
|
|
509
|
+
statements(db: number, sql: string, options?: SQLitePrepareOptions): AsyncIterable<number>;
|
|
510
|
+
/**
|
|
511
|
+
* Evaluate an SQL statement
|
|
512
|
+
* @see https://www.sqlite.org/c3ref/step.html
|
|
513
|
+
* @param stmt prepared statement pointer
|
|
514
|
+
* @returns Promise resolving to `SQLITE_ROW` or `SQLITE_DONE`
|
|
515
|
+
* (rejects on error)
|
|
516
|
+
*/
|
|
517
|
+
step(stmt: number): Promise<number>;
|
|
518
|
+
/**
|
|
519
|
+
* Register an update hook
|
|
520
|
+
*
|
|
521
|
+
* The callback is invoked whenever a row is updated, inserted, or deleted
|
|
522
|
+
* in a rowid table on this connection.
|
|
523
|
+
* @see https://www.sqlite.org/c3ref/update_hook.html
|
|
524
|
+
*
|
|
525
|
+
* updateType is one of:
|
|
526
|
+
* - SQLITE_DELETE: 9
|
|
527
|
+
* - SQLITE_INSERT: 18
|
|
528
|
+
* - SQLITE_UPDATE: 23
|
|
529
|
+
* @see https://www.sqlite.org/c3ref/c_alter_table.html
|
|
530
|
+
*
|
|
531
|
+
* @param db database pointer
|
|
532
|
+
* @param callback
|
|
533
|
+
*/
|
|
534
|
+
update_hook(db: number, callback: (updateType: number, dbName: string | null, tblName: string | null, rowid: bigint) => void): void;
|
|
535
|
+
/**
|
|
536
|
+
* Extract a value from `sqlite3_value`
|
|
537
|
+
*
|
|
538
|
+
* This is a convenience function that calls the appropriate `value_*`
|
|
539
|
+
* function based on its type. Note that if the value is a blob then as
|
|
540
|
+
* with `value_blob` the result may be invalid after the next SQLite call.
|
|
541
|
+
*
|
|
542
|
+
* Integer values are returned as Number if within the min/max safe
|
|
543
|
+
* integer bounds, otherwise they are returned as BigInt.
|
|
544
|
+
* @param pValue `sqlite3_value` pointer
|
|
545
|
+
* @returns value
|
|
546
|
+
*/
|
|
547
|
+
value(pValue: number): SQLiteCompatibleType;
|
|
548
|
+
/**
|
|
549
|
+
* Extract a value from `sqlite3_value`
|
|
550
|
+
*
|
|
551
|
+
* The contents of the returned buffer may be invalid after the
|
|
552
|
+
* next SQLite call. Make a copy of the data (e.g. with `.slice()`)
|
|
553
|
+
* if longer retention is required.
|
|
554
|
+
* @see https://sqlite.org/c3ref/value_blob.html
|
|
555
|
+
* @param pValue `sqlite3_value` pointer
|
|
556
|
+
* @returns value
|
|
557
|
+
*/
|
|
558
|
+
value_blob(pValue: number): Uint8Array;
|
|
559
|
+
/**
|
|
560
|
+
* Get blob or text size for value
|
|
561
|
+
* @see https://sqlite.org/c3ref/value_blob.html
|
|
562
|
+
* @param pValue `sqlite3_value` pointer
|
|
563
|
+
* @returns size
|
|
564
|
+
*/
|
|
565
|
+
value_bytes(pValue: number): number;
|
|
566
|
+
/**
|
|
567
|
+
* Extract a value from `sqlite3_value`
|
|
568
|
+
* @see https://sqlite.org/c3ref/value_blob.html
|
|
569
|
+
* @param pValue `sqlite3_value` pointer
|
|
570
|
+
* @returns value
|
|
571
|
+
*/
|
|
572
|
+
value_double(pValue: number): number;
|
|
573
|
+
/**
|
|
574
|
+
* Extract a value from `sqlite3_value`
|
|
575
|
+
* @see https://sqlite.org/c3ref/value_blob.html
|
|
576
|
+
* @param pValue `sqlite3_value` pointer
|
|
577
|
+
* @returns value
|
|
578
|
+
*/
|
|
579
|
+
value_int(pValue: number): number;
|
|
580
|
+
/**
|
|
581
|
+
* Extract a value from `sqlite3_value`
|
|
582
|
+
* @see https://sqlite.org/c3ref/value_blob.html
|
|
583
|
+
* @param pValue `sqlite3_value` pointer
|
|
584
|
+
* @returns value
|
|
585
|
+
*/
|
|
586
|
+
value_int64(pValue: number): bigint;
|
|
587
|
+
/**
|
|
588
|
+
* Extract a value from `sqlite3_value`
|
|
589
|
+
* @see https://sqlite.org/c3ref/value_blob.html
|
|
590
|
+
* @param pValue `sqlite3_value` pointer
|
|
591
|
+
* @returns value
|
|
592
|
+
*/
|
|
593
|
+
value_text(pValue: number): string;
|
|
594
|
+
/**
|
|
595
|
+
* Get type of `sqlite3_value`
|
|
596
|
+
* @see https://sqlite.org/c3ref/value_blob.html
|
|
597
|
+
* @param pValue `sqlite3_value` pointer
|
|
598
|
+
* @returns enumeration value for type
|
|
599
|
+
*/
|
|
600
|
+
value_type(pValue: number): number;
|
|
601
|
+
/**
|
|
602
|
+
* Register a new Virtual File System.
|
|
603
|
+
*
|
|
604
|
+
* @see https://www.sqlite.org/c3ref/vfs_find.html
|
|
605
|
+
* @param vfs VFS object
|
|
606
|
+
* @param makeDefault
|
|
607
|
+
* @returns `SQLITE_OK` (throws exception on error)
|
|
608
|
+
*/
|
|
609
|
+
vfs_register(vfs: any, makeDefault?: boolean): number;
|
|
610
|
+
}
|
|
611
|
+
export {};
|