@photostructure/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/CHANGELOG.md +43 -0
- package/LICENSE +21 -0
- package/README.md +522 -0
- package/SECURITY.md +114 -0
- package/binding.gyp +94 -0
- package/dist/index.cjs +134 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +408 -0
- package/dist/index.d.mts +408 -0
- package/dist/index.d.ts +408 -0
- package/dist/index.mjs +103 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +144 -0
- package/prebuilds/darwin-arm64/@photostructure+sqlite.glibc.node +0 -0
- package/prebuilds/linux-arm64/@photostructure+sqlite.glibc.node +0 -0
- package/prebuilds/linux-arm64/@photostructure+sqlite.musl.node +0 -0
- package/prebuilds/linux-x64/@photostructure+sqlite.glibc.node +0 -0
- package/prebuilds/linux-x64/@photostructure+sqlite.musl.node +0 -0
- package/prebuilds/win32-x64/@photostructure+sqlite.glibc.node +0 -0
- package/scripts/post-build.mjs +21 -0
- package/scripts/prebuild-linux-glibc.sh +108 -0
- package/src/aggregate_function.cpp +417 -0
- package/src/aggregate_function.h +116 -0
- package/src/binding.cpp +160 -0
- package/src/dirname.ts +13 -0
- package/src/index.ts +465 -0
- package/src/shims/base_object-inl.h +8 -0
- package/src/shims/base_object.h +50 -0
- package/src/shims/debug_utils-inl.h +23 -0
- package/src/shims/env-inl.h +19 -0
- package/src/shims/memory_tracker-inl.h +17 -0
- package/src/shims/napi_extensions.h +73 -0
- package/src/shims/node.h +16 -0
- package/src/shims/node_errors.h +66 -0
- package/src/shims/node_mem-inl.h +8 -0
- package/src/shims/node_mem.h +31 -0
- package/src/shims/node_url.h +23 -0
- package/src/shims/promise_resolver.h +31 -0
- package/src/shims/util-inl.h +18 -0
- package/src/shims/util.h +101 -0
- package/src/sqlite_impl.cpp +2440 -0
- package/src/sqlite_impl.h +314 -0
- package/src/stack_path.ts +64 -0
- package/src/types/node-gyp-build.d.ts +4 -0
- package/src/upstream/node_sqlite.cc +2706 -0
- package/src/upstream/node_sqlite.h +234 -0
- package/src/upstream/sqlite.gyp +38 -0
- package/src/upstream/sqlite.js +19 -0
- package/src/upstream/sqlite3.c +262809 -0
- package/src/upstream/sqlite3.h +13773 -0
- package/src/upstream/sqlite3ext.h +723 -0
- package/src/user_function.cpp +225 -0
- package/src/user_function.h +40 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration options for opening a database.
|
|
3
|
+
* This interface matches Node.js sqlite module's DatabaseSyncOptions.
|
|
4
|
+
*/
|
|
5
|
+
interface DatabaseSyncOptions {
|
|
6
|
+
/** Path to the database file. Use ':memory:' for an in-memory database. */
|
|
7
|
+
readonly location?: string;
|
|
8
|
+
/** If true, the database is opened in read-only mode. @default false */
|
|
9
|
+
readonly readOnly?: boolean;
|
|
10
|
+
/** If true, foreign key constraints are enforced. @default true */
|
|
11
|
+
readonly enableForeignKeyConstraints?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* If true, double-quoted string literals are allowed.
|
|
14
|
+
*
|
|
15
|
+
* If enabled, double quotes can be misinterpreted as identifiers instead of
|
|
16
|
+
* string literals, leading to confusing errors.
|
|
17
|
+
*
|
|
18
|
+
* **The SQLite documentation strongly recommends avoiding double-quoted
|
|
19
|
+
* strings entirely.**
|
|
20
|
+
|
|
21
|
+
* @see https://sqlite.org/quirks.html#dblquote
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
readonly enableDoubleQuotedStringLiterals?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Sets the busy timeout in milliseconds.
|
|
27
|
+
* @default 5000
|
|
28
|
+
*/
|
|
29
|
+
readonly timeout?: number;
|
|
30
|
+
/** If true, enables loading of SQLite extensions. @default false */
|
|
31
|
+
readonly allowExtension?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Options for creating a prepared statement.
|
|
35
|
+
*/
|
|
36
|
+
interface StatementOptions {
|
|
37
|
+
/** If true, the prepared statement's expandedSQL property will contain the expanded SQL. @default false */
|
|
38
|
+
readonly expandedSQL?: boolean;
|
|
39
|
+
/** If true, anonymous parameters are enabled for the statement. @default false */
|
|
40
|
+
readonly anonymousParameters?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A prepared SQL statement that can be executed multiple times with different parameters.
|
|
44
|
+
* This interface represents an instance of the StatementSync class.
|
|
45
|
+
*/
|
|
46
|
+
interface StatementSyncInstance {
|
|
47
|
+
/** The original SQL source string. */
|
|
48
|
+
readonly sourceSQL: string;
|
|
49
|
+
/** The expanded SQL string with bound parameters, if expandedSQL option was set. */
|
|
50
|
+
readonly expandedSQL: string | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* This method executes a prepared statement and returns an object.
|
|
53
|
+
* @param parameters Optional named and anonymous parameters to bind to the statement.
|
|
54
|
+
* @returns An object with the number of changes and the last insert rowid.
|
|
55
|
+
*/
|
|
56
|
+
run(...parameters: any[]): {
|
|
57
|
+
changes: number;
|
|
58
|
+
lastInsertRowid: number | bigint;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* This method executes a prepared statement and returns the first result row.
|
|
62
|
+
* @param parameters Optional named and anonymous parameters to bind to the statement.
|
|
63
|
+
* @returns The first row from the query results, or undefined if no rows.
|
|
64
|
+
*/
|
|
65
|
+
get(...parameters: any[]): any;
|
|
66
|
+
/**
|
|
67
|
+
* This method executes a prepared statement and returns all results as an array.
|
|
68
|
+
* @param parameters Optional named and anonymous parameters to bind to the statement.
|
|
69
|
+
* @returns An array of row objects from the query results.
|
|
70
|
+
*/
|
|
71
|
+
all(...parameters: any[]): any[];
|
|
72
|
+
/**
|
|
73
|
+
* This method executes a prepared statement and returns an iterable iterator of objects.
|
|
74
|
+
* Each object represents a row from the query results.
|
|
75
|
+
* @param parameters Optional named and anonymous parameters to bind to the statement.
|
|
76
|
+
* @returns An iterable iterator of row objects.
|
|
77
|
+
*/
|
|
78
|
+
iterate(...parameters: any[]): IterableIterator<any>;
|
|
79
|
+
/**
|
|
80
|
+
* Set whether to read integer values as JavaScript BigInt.
|
|
81
|
+
* @param readBigInts If true, read integers as BigInts. @default false
|
|
82
|
+
*/
|
|
83
|
+
setReadBigInts(readBigInts: boolean): void;
|
|
84
|
+
/**
|
|
85
|
+
* Set whether to allow bare named parameters in SQL.
|
|
86
|
+
* @param allowBareNamedParameters If true, allows bare named parameters. @default false
|
|
87
|
+
*/
|
|
88
|
+
setAllowBareNamedParameters(allowBareNamedParameters: boolean): void;
|
|
89
|
+
/**
|
|
90
|
+
* Set whether to return results as arrays rather than objects.
|
|
91
|
+
* @param returnArrays If true, return results as arrays. @default false
|
|
92
|
+
*/
|
|
93
|
+
setReturnArrays(returnArrays: boolean): void;
|
|
94
|
+
/**
|
|
95
|
+
* Returns an array of objects, each representing a column in the statement's result set.
|
|
96
|
+
* Each object has a 'name' property for the column name and a 'type' property for the SQLite type.
|
|
97
|
+
* @returns Array of column metadata objects.
|
|
98
|
+
*/
|
|
99
|
+
columns(): Array<{
|
|
100
|
+
name: string;
|
|
101
|
+
type?: string;
|
|
102
|
+
}>;
|
|
103
|
+
/**
|
|
104
|
+
* Finalizes the prepared statement and releases its resources.
|
|
105
|
+
* Called automatically by Symbol.dispose.
|
|
106
|
+
*/
|
|
107
|
+
finalize(): void;
|
|
108
|
+
/** Dispose of the statement resources using the explicit resource management protocol. */
|
|
109
|
+
[Symbol.dispose](): void;
|
|
110
|
+
}
|
|
111
|
+
interface UserFunctionOptions {
|
|
112
|
+
/** If `true`, sets the `SQLITE_DETERMINISTIC` flag. @default false */
|
|
113
|
+
readonly deterministic?: boolean;
|
|
114
|
+
/** If `true`, sets the `SQLITE_DIRECTONLY` flag. @default false */
|
|
115
|
+
readonly directOnly?: boolean;
|
|
116
|
+
/** If `true`, converts integer arguments to `BigInt`s. @default false */
|
|
117
|
+
readonly useBigIntArguments?: boolean;
|
|
118
|
+
/** If `true`, allows function to be invoked with variable arguments. @default false */
|
|
119
|
+
readonly varargs?: boolean;
|
|
120
|
+
}
|
|
121
|
+
interface AggregateOptions {
|
|
122
|
+
/** The initial value for the aggregation. */
|
|
123
|
+
readonly start?: any;
|
|
124
|
+
/** Function called for each row to update the aggregate state. */
|
|
125
|
+
readonly step: (accumulator: any, ...args: any[]) => any;
|
|
126
|
+
/** Optional function for window function support to reverse a step. */
|
|
127
|
+
readonly inverse?: (accumulator: any, ...args: any[]) => any;
|
|
128
|
+
/** Optional function to compute the final result from the accumulator. */
|
|
129
|
+
readonly result?: (accumulator: any) => any;
|
|
130
|
+
/** If `true`, sets the `SQLITE_DETERMINISTIC` flag. @default false */
|
|
131
|
+
readonly deterministic?: boolean;
|
|
132
|
+
/** If `true`, sets the `SQLITE_DIRECTONLY` flag. @default false */
|
|
133
|
+
readonly directOnly?: boolean;
|
|
134
|
+
/** If `true`, converts integer arguments to `BigInt`s. @default false */
|
|
135
|
+
readonly useBigIntArguments?: boolean;
|
|
136
|
+
/** If `true`, allows function to be invoked with variable arguments. @default false */
|
|
137
|
+
readonly varargs?: boolean;
|
|
138
|
+
}
|
|
139
|
+
interface SessionOptions {
|
|
140
|
+
/** The table to track changes for. If omitted, all tables are tracked. */
|
|
141
|
+
readonly table?: string;
|
|
142
|
+
/** The database name. @default "main" */
|
|
143
|
+
readonly db?: string;
|
|
144
|
+
}
|
|
145
|
+
interface ChangesetApplyOptions {
|
|
146
|
+
/**
|
|
147
|
+
* Function called when a conflict is detected during changeset application.
|
|
148
|
+
* @param conflictType The type of conflict (SQLITE_CHANGESET_CONFLICT, etc.)
|
|
149
|
+
* @returns One of SQLITE_CHANGESET_OMIT, SQLITE_CHANGESET_REPLACE, or SQLITE_CHANGESET_ABORT
|
|
150
|
+
*/
|
|
151
|
+
readonly onConflict?: (conflictType: number) => number;
|
|
152
|
+
/**
|
|
153
|
+
* Function called to filter which tables to apply changes to.
|
|
154
|
+
* @param tableName The name of the table
|
|
155
|
+
* @returns true to include the table, false to skip it
|
|
156
|
+
*/
|
|
157
|
+
readonly filter?: (tableName: string) => boolean;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Represents a SQLite database connection.
|
|
161
|
+
* This interface represents an instance of the DatabaseSync class.
|
|
162
|
+
*/
|
|
163
|
+
interface DatabaseSyncInstance {
|
|
164
|
+
/** Indicates whether the database connection is open. */
|
|
165
|
+
readonly isOpen: boolean;
|
|
166
|
+
/** Indicates whether a transaction is currently active. */
|
|
167
|
+
readonly isTransaction: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Opens a database connection. This method is called automatically when creating
|
|
170
|
+
* a DatabaseSync instance, so typically should not be called directly.
|
|
171
|
+
* @param configuration Optional configuration for opening the database.
|
|
172
|
+
*/
|
|
173
|
+
open(configuration?: DatabaseSyncOptions): void;
|
|
174
|
+
/**
|
|
175
|
+
* Closes the database connection. This method should be called to ensure that
|
|
176
|
+
* the database connection is properly cleaned up. Once a database is closed,
|
|
177
|
+
* it cannot be used again.
|
|
178
|
+
*/
|
|
179
|
+
close(): void;
|
|
180
|
+
/**
|
|
181
|
+
* Returns the location of the database file. For attached databases, you can specify
|
|
182
|
+
* the database name. Returns null for in-memory databases.
|
|
183
|
+
* @param dbName The name of the database. Defaults to 'main' (the primary database).
|
|
184
|
+
* @returns The file path of the database, or null for in-memory databases.
|
|
185
|
+
*/
|
|
186
|
+
location(dbName?: string): string | null;
|
|
187
|
+
/**
|
|
188
|
+
* Compiles an SQL statement and returns a StatementSyncInstance object.
|
|
189
|
+
* @param sql The SQL statement to prepare.
|
|
190
|
+
* @param options Optional configuration for the statement.
|
|
191
|
+
* @returns A StatementSyncInstance object that can be executed multiple times.
|
|
192
|
+
*/
|
|
193
|
+
prepare(sql: string, options?: StatementOptions): StatementSyncInstance;
|
|
194
|
+
/**
|
|
195
|
+
* This method allows one or more SQL statements to be executed without
|
|
196
|
+
* returning any results. This is useful for commands like CREATE TABLE,
|
|
197
|
+
* INSERT, UPDATE, or DELETE.
|
|
198
|
+
* @param sql The SQL statement(s) to execute.
|
|
199
|
+
*/
|
|
200
|
+
exec(sql: string): void;
|
|
201
|
+
/**
|
|
202
|
+
* This method creates SQLite user-defined functions, wrapping sqlite3_create_function_v2().
|
|
203
|
+
* @param name The name of the SQLite function to create.
|
|
204
|
+
* @param func The JavaScript function to call when the SQLite function is invoked.
|
|
205
|
+
*/
|
|
206
|
+
function(name: string, func: Function): void;
|
|
207
|
+
/**
|
|
208
|
+
* This method creates SQLite user-defined functions, wrapping sqlite3_create_function_v2().
|
|
209
|
+
* @param name The name of the SQLite function to create.
|
|
210
|
+
* @param options Optional configuration settings.
|
|
211
|
+
* @param func The JavaScript function to call when the SQLite function is invoked.
|
|
212
|
+
*/
|
|
213
|
+
function(name: string, options: UserFunctionOptions, func: Function): void;
|
|
214
|
+
/**
|
|
215
|
+
* This method creates SQLite aggregate functions, wrapping sqlite3_create_window_function().
|
|
216
|
+
* @param name The name of the SQLite aggregate function to create.
|
|
217
|
+
* @param options Configuration object containing step function and other settings.
|
|
218
|
+
*/
|
|
219
|
+
aggregate(name: string, options: AggregateOptions): void;
|
|
220
|
+
/**
|
|
221
|
+
* Create a new session to record database changes.
|
|
222
|
+
* @param options Optional configuration for the session.
|
|
223
|
+
* @returns A Session object for recording changes.
|
|
224
|
+
*/
|
|
225
|
+
createSession(options?: SessionOptions): Session;
|
|
226
|
+
/**
|
|
227
|
+
* Apply a changeset to the database.
|
|
228
|
+
* @param changeset The changeset data to apply.
|
|
229
|
+
* @param options Optional configuration for applying the changeset.
|
|
230
|
+
* @returns true if successful, false if aborted.
|
|
231
|
+
*/
|
|
232
|
+
applyChangeset(changeset: Buffer, options?: ChangesetApplyOptions): boolean;
|
|
233
|
+
/**
|
|
234
|
+
* Enables or disables the loading of SQLite extensions.
|
|
235
|
+
* @param enable If true, enables extension loading. If false, disables it.
|
|
236
|
+
*/
|
|
237
|
+
enableLoadExtension(enable: boolean): void;
|
|
238
|
+
/**
|
|
239
|
+
* Loads an SQLite extension from the specified file path.
|
|
240
|
+
* @param path The path to the extension library.
|
|
241
|
+
* @param entryPoint Optional entry point function name. If not provided, uses the default entry point.
|
|
242
|
+
*/
|
|
243
|
+
loadExtension(path: string, entryPoint?: string): void;
|
|
244
|
+
/**
|
|
245
|
+
* Makes a backup of the database. This method abstracts the sqlite3_backup_init(),
|
|
246
|
+
* sqlite3_backup_step() and sqlite3_backup_finish() functions.
|
|
247
|
+
*
|
|
248
|
+
* The backed-up database can be used normally during the backup process. Mutations
|
|
249
|
+
* coming from the same connection will be reflected in the backup right away.
|
|
250
|
+
* However, mutations from other connections will cause the backup process to restart.
|
|
251
|
+
*
|
|
252
|
+
* @param path The path where the backup will be created. If the file already exists, the contents will be overwritten.
|
|
253
|
+
* @param options Optional configuration for the backup operation.
|
|
254
|
+
* @param options.rate Number of pages to be transmitted in each batch of the backup. @default 100
|
|
255
|
+
* @param options.source Name of the source database. This can be 'main' (the default primary database) or any other database that have been added with ATTACH DATABASE. @default 'main'
|
|
256
|
+
* @param options.target Name of the target database. This can be 'main' (the default primary database) or any other database that have been added with ATTACH DATABASE. @default 'main'
|
|
257
|
+
* @param options.progress Callback function that will be called with the number of pages copied and the total number of pages.
|
|
258
|
+
* @returns A promise that resolves when the backup is completed and rejects if an error occurs.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* // Basic backup
|
|
262
|
+
* await db.backup('./backup.db');
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* // Backup with progress
|
|
266
|
+
* await db.backup('./backup.db', {
|
|
267
|
+
* rate: 10,
|
|
268
|
+
* progress: ({ totalPages, remainingPages }) => {
|
|
269
|
+
* console.log(`Progress: ${totalPages - remainingPages}/${totalPages}`);
|
|
270
|
+
* }
|
|
271
|
+
* });
|
|
272
|
+
*/
|
|
273
|
+
backup(path: string | Buffer | URL, options?: {
|
|
274
|
+
rate?: number;
|
|
275
|
+
source?: string;
|
|
276
|
+
target?: string;
|
|
277
|
+
progress?: (info: {
|
|
278
|
+
totalPages: number;
|
|
279
|
+
remainingPages: number;
|
|
280
|
+
}) => void;
|
|
281
|
+
}): Promise<number>;
|
|
282
|
+
/** Dispose of the database resources using the explicit resource management protocol. */
|
|
283
|
+
[Symbol.dispose](): void;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* The main SQLite module interface.
|
|
287
|
+
*/
|
|
288
|
+
interface SqliteModule {
|
|
289
|
+
/**
|
|
290
|
+
* The DatabaseSync class represents a synchronous connection to a SQLite database.
|
|
291
|
+
* All operations are performed synchronously, blocking until completion.
|
|
292
|
+
*/
|
|
293
|
+
DatabaseSync: new (location?: string | Buffer | URL, options?: DatabaseSyncOptions) => DatabaseSyncInstance;
|
|
294
|
+
/**
|
|
295
|
+
* The StatementSync class represents a synchronous prepared statement.
|
|
296
|
+
* This class should not be instantiated directly; use Database.prepare() instead.
|
|
297
|
+
*/
|
|
298
|
+
StatementSync: new (database: DatabaseSyncInstance, sql: string, options?: StatementOptions) => StatementSyncInstance;
|
|
299
|
+
/**
|
|
300
|
+
* The Session class for recording database changes.
|
|
301
|
+
* This class should not be instantiated directly; use Database.createSession() instead.
|
|
302
|
+
*/
|
|
303
|
+
Session: new () => Session;
|
|
304
|
+
/**
|
|
305
|
+
* SQLite constants for various operations and flags.
|
|
306
|
+
*/
|
|
307
|
+
constants: {
|
|
308
|
+
/** Open database for reading only. */
|
|
309
|
+
SQLITE_OPEN_READONLY: number;
|
|
310
|
+
/** Open database for reading and writing. */
|
|
311
|
+
SQLITE_OPEN_READWRITE: number;
|
|
312
|
+
/** Create database if it doesn't exist. */
|
|
313
|
+
SQLITE_OPEN_CREATE: number;
|
|
314
|
+
/** Skip conflicting changes. */
|
|
315
|
+
SQLITE_CHANGESET_OMIT: number;
|
|
316
|
+
/** Replace conflicting changes. */
|
|
317
|
+
SQLITE_CHANGESET_REPLACE: number;
|
|
318
|
+
/** Abort on conflict. */
|
|
319
|
+
SQLITE_CHANGESET_ABORT: number;
|
|
320
|
+
/** Data conflict type. */
|
|
321
|
+
SQLITE_CHANGESET_DATA: number;
|
|
322
|
+
/** Row not found conflict. */
|
|
323
|
+
SQLITE_CHANGESET_NOTFOUND: number;
|
|
324
|
+
/** General conflict. */
|
|
325
|
+
SQLITE_CHANGESET_CONFLICT: number;
|
|
326
|
+
/** Constraint violation. */
|
|
327
|
+
SQLITE_CHANGESET_CONSTRAINT: number;
|
|
328
|
+
/** Foreign key constraint violation. */
|
|
329
|
+
SQLITE_CHANGESET_FOREIGN_KEY: number;
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* The DatabaseSync class represents a synchronous connection to a SQLite database.
|
|
334
|
+
* All database operations are performed synchronously, blocking the thread until completion.
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* ```typescript
|
|
338
|
+
* import { DatabaseSync } from '@photostructure/sqlite';
|
|
339
|
+
*
|
|
340
|
+
* // Create an in-memory database
|
|
341
|
+
* const db = new DatabaseSync(':memory:');
|
|
342
|
+
*
|
|
343
|
+
* // Create a file-based database
|
|
344
|
+
* const fileDb = new DatabaseSync('./mydata.db');
|
|
345
|
+
*
|
|
346
|
+
* // Create with options
|
|
347
|
+
* const readOnlyDb = new DatabaseSync('./data.db', { readOnly: true });
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
350
|
+
declare const DatabaseSync: SqliteModule["DatabaseSync"];
|
|
351
|
+
/**
|
|
352
|
+
* The StatementSync class represents a prepared SQL statement.
|
|
353
|
+
* This class should not be instantiated directly; use DatabaseSync.prepare() instead.
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* ```typescript
|
|
357
|
+
* const stmt = db.prepare('SELECT * FROM users WHERE id = ?');
|
|
358
|
+
* const user = stmt.get(123);
|
|
359
|
+
* stmt.finalize();
|
|
360
|
+
* ```
|
|
361
|
+
*/
|
|
362
|
+
declare const StatementSync: SqliteModule["StatementSync"];
|
|
363
|
+
interface Session {
|
|
364
|
+
/**
|
|
365
|
+
* Generate a changeset containing all changes recorded by the session.
|
|
366
|
+
* @returns A Buffer containing the changeset data.
|
|
367
|
+
*/
|
|
368
|
+
changeset(): Buffer;
|
|
369
|
+
/**
|
|
370
|
+
* Generate a patchset containing all changes recorded by the session.
|
|
371
|
+
* @returns A Buffer containing the patchset data.
|
|
372
|
+
*/
|
|
373
|
+
patchset(): Buffer;
|
|
374
|
+
/**
|
|
375
|
+
* Close the session and release its resources.
|
|
376
|
+
*/
|
|
377
|
+
close(): void;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* The Session class for recording database changes.
|
|
381
|
+
* This class should not be instantiated directly; use DatabaseSync.createSession() instead.
|
|
382
|
+
*
|
|
383
|
+
* @example
|
|
384
|
+
* ```typescript
|
|
385
|
+
* const session = db.createSession({ table: 'users' });
|
|
386
|
+
* // Make some changes to the users table
|
|
387
|
+
* const changeset = session.changeset();
|
|
388
|
+
* session.close();
|
|
389
|
+
* ```
|
|
390
|
+
*/
|
|
391
|
+
declare const Session: SqliteModule["Session"];
|
|
392
|
+
/**
|
|
393
|
+
* SQLite constants for various operations and flags.
|
|
394
|
+
*
|
|
395
|
+
* @example
|
|
396
|
+
* ```typescript
|
|
397
|
+
* import { constants } from '@photostructure/sqlite';
|
|
398
|
+
*
|
|
399
|
+
* const db = new DatabaseSync('./data.db', {
|
|
400
|
+
* readOnly: true,
|
|
401
|
+
* // Uses SQLITE_OPEN_READONLY internally
|
|
402
|
+
* });
|
|
403
|
+
* ```
|
|
404
|
+
*/
|
|
405
|
+
declare const constants: SqliteModule["constants"];
|
|
406
|
+
declare const _default: SqliteModule;
|
|
407
|
+
|
|
408
|
+
export { type AggregateOptions, type ChangesetApplyOptions, DatabaseSync, type DatabaseSyncInstance, type DatabaseSyncOptions, Session, type SessionOptions, type SqliteModule, type StatementOptions, StatementSync, type StatementSyncInstance, type UserFunctionOptions, constants, _default as default };
|