/
SQLite.types.d.ts
68 lines (68 loc) · 2.16 KB
/
SQLite.types.d.ts
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
export interface Window {
openDatabase?: (name: string, version: string, displayName: string, estimatedSize: number, creationCallback?: DatabaseCallback) => Database;
}
export interface DatabaseCallback {
(database: Database): void;
}
export interface Database {
version: string;
transaction(callback: SQLTransactionCallback, errorCallback?: SQLTransactionErrorCallback, successCallback?: SQLVoidCallback): void;
readTransaction(callback: SQLTransactionCallback, errorCallback?: SQLTransactionErrorCallback, successCallback?: SQLVoidCallback): void;
}
export interface SQLVoidCallback {
(): void;
}
export interface SQLTransactionCallback {
(transaction: SQLTransaction): void;
}
export interface SQLTransactionErrorCallback {
(error: SQLError): void;
}
export interface SQLTransaction {
executeSql(sqlStatement: string, args?: any[], callback?: SQLStatementCallback, errorCallback?: SQLStatementErrorCallback): void;
}
export interface SQLStatementCallback {
(transaction: SQLTransaction, resultSet: SQLResultSet): void;
}
export interface SQLStatementErrorCallback {
(transaction: SQLTransaction, error: SQLError): boolean;
}
export interface SQLResultSet {
insertId: number;
rowsAffected: number;
rows: SQLResultSetRowList;
}
export interface SQLResultSetRowList {
length: number;
item(index: number): any;
}
export declare class SQLError {
static UNKNOWN_ERR: number;
static DATABASE_ERR: number;
static VERSION_ERR: number;
static TOO_LARGE_ERR: number;
static QUOTA_ERR: number;
static SYNTAX_ERR: number;
static CONSTRAINT_ERR: number;
static TIMEOUT_ERR: number;
code: number;
message: string;
}
export interface WebSQLDatabase extends Database {
exec(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void;
}
export declare type Query = {
sql: string;
args: unknown[];
};
export interface ResultSetError {
error: Error;
}
export interface ResultSet {
insertId?: number;
rowsAffected: number;
rows: {
[column: string]: any;
}[];
}
export declare type SQLiteCallback = (error?: Error | null, resultSet?: (ResultSetError | ResultSet)[]) => void;