-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathindex.d.ts
More file actions
196 lines (194 loc) · 5.65 KB
/
index.d.ts
File metadata and controls
196 lines (194 loc) · 5.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
/** SQLite connection options. */
export interface Options {
timeout?: number
authToken?: string
syncUrl?: string
readYourWrites?: boolean
syncPeriod?: number
encryptionCipher?: string
encryptionKey?: string
remoteEncryptionKey?: string
defaultQueryTimeout?: number
}
/** Per-query execution options. */
export interface QueryOptions {
queryTimeout?: number
}
export declare function connect(path: string, opts?: Options | undefined | null): Promise<Database>
/** Result of a database sync operation. */
export interface SyncResult {
/** The number of frames synced. */
framesSynced: number
/** The replication index. */
replicationIndex: number
}
/** Prepares a statement in blocking mode. */
export declare function databasePrepareSync(db: Database, sql: string): Statement
/** Syncs the database in blocking mode. */
export declare function databaseSyncSync(db: Database): SyncResult
/** Executes SQL in blocking mode. */
export declare function databaseExecSync(db: Database, sql: string, queryOptions?: QueryOptions | undefined | null): void
/** Gets first row from statement in blocking mode. */
export declare function statementGetSync(stmt: Statement, params?: unknown | undefined | null, queryOptions?: QueryOptions | undefined | null): unknown
/** Runs a statement in blocking mode. */
export declare function statementRunSync(stmt: Statement, params?: unknown | undefined | null, queryOptions?: QueryOptions | undefined | null): RunResult
export declare function statementIterateSync(stmt: Statement, params?: unknown | undefined | null, queryOptions?: QueryOptions | undefined | null): RowsIterator
/** SQLite `run()` result object */
export interface RunResult {
changes: number
duration: number
lastInsertRowid: number
}
/** Retrieve next row from an iterator synchronously. Needed for better-sqlite3 API compatibility. */
export declare function iteratorNextSync(iter: RowsIterator): Record
/** SQLite database connection. */
export declare class Database {
/**
* Creates a new database instance.
*
* # Arguments
*
* * `path` - The path to the database file.
* * `opts` - The database options.
*/
constructor(path: string, opts?: Options | undefined | null)
/** Returns whether the database is in memory-only mode. */
get memory(): boolean
/** Returns whether the database is in a transaction. */
inTransaction(): boolean
/**
* Prepares a statement for execution.
*
* # Arguments
*
* * `sql` - The SQL statement to prepare.
*
* # Returns
*
* A `Statement` instance.
*/
prepare(sql: string): Promise<Statement>
/**
* Sets the authorizer for the database.
*
* # Arguments
*
* * `env` - The environment.
* * `rules_obj` - The rules object.
*
* The `rules_obj` is a JavaScript object with the following properties:
*
* * `Authorization.ALLOW` - Allow access to the table.
* * `Authorization.DENY` - Deny access to the table.
*
* Example:
*
* ```javascript
* db.authorizer({
* "users": Authorization.ALLOW
* });
* ```
*/
authorizer(rulesObj: object): void
/**
* Loads an extension into the database.
*
* # Arguments
*
* * `path` - The path to the extension file.
* * `entry_point` - The entry point of the extension.
*
*/
loadExtension(path: string, entryPoint?: string | undefined | null): void
/**
* Returns the maximum write replication index.
*
* # Returns
*
* The maximum write replication index.
*/
maxWriteReplicationIndex(): number
/**
* Executes a SQL statement.
*
* # Arguments
*
* * `env` - The environment.
* * `sql` - The SQL statement to execute.
*/
exec(sql: string, queryOptions?: QueryOptions | undefined | null): Promise<void>
/**
* Syncs the database.
*
* # Returns
*
* A `SyncResult` instance.
*/
sync(): Promise<SyncResult>
/**
* Interrupts any ongoing database operations.
*
* # Arguments
*
* * `env` - The environment.
*/
interrupt(): void
/** Closes the database connection. */
close(): void
/**
* Sets the default safe integers mode.
*
* # Arguments
*
* * `toggle` - Whether to use safe integers by default.
*/
defaultSafeIntegers(toggle?: boolean | undefined | null): void
}
/** SQLite statement object. */
export declare class Statement {
/**
* Executes a SQL statement.
*
* # Arguments
*
* * `params` - The parameters to bind to the statement.
*/
run(params?: unknown | undefined | null, queryOptions?: QueryOptions | undefined | null): object
/**
* Executes a SQL statement and returns the first row.
*
* # Arguments
*
* * `env` - The environment.
* * `params` - The parameters to bind to the statement.
*/
get(params?: unknown | undefined | null, queryOptions?: QueryOptions | undefined | null): object
/**
* Create an iterator over the rows of a statement.
*
* # Arguments
*
* * `env` - The environment.
* * `params` - The parameters to bind to the statement.
*/
iterate(params?: unknown | undefined | null, queryOptions?: QueryOptions | undefined | null): object
raw(raw?: boolean | undefined | null): this
pluck(pluck?: boolean | undefined | null): this
timing(timing?: boolean | undefined | null): this
columns(): unknown[]
safeIntegers(toggle?: boolean | undefined | null): this
interrupt(): void
/** Closes the statement. */
close(): void
}
/** A raw iterator over rows. The JavaScript layer wraps this in a iterable. */
export declare class RowsIterator {
next(): Promise<Record>
}
export declare class Record {
get value(): unknown
get done(): boolean
}