1export interface Window { 2 openDatabase?: (name: string, version: string, displayName: string, estimatedSize: number, creationCallback?: DatabaseCallback) => Database; 3} 4export declare type DatabaseCallback = (database: Database) => void; 5/** 6 * `Database` objects are returned by calls to `SQLite.openDatabase()`. Such an object represents a 7 * connection to a database on your device. 8 */ 9export interface Database { 10 version: string; 11 /** 12 * Execute a database transaction. 13 * @param callback A function representing the transaction to perform. Takes a Transaction 14 * (see below) as its only parameter, on which it can add SQL statements to execute. 15 * @param errorCallback Called if an error occurred processing this transaction. Takes a single 16 * parameter describing the error. 17 * @param successCallback Called when the transaction has completed executing on the database. 18 */ 19 transaction(callback: SQLTransactionCallback, errorCallback?: SQLTransactionErrorCallback, successCallback?: () => void): void; 20 readTransaction(callback: SQLTransactionCallback, errorCallback?: SQLTransactionErrorCallback, successCallback?: () => void): void; 21} 22export declare type SQLTransactionCallback = (transaction: SQLTransaction) => void; 23export declare type SQLTransactionErrorCallback = (error: SQLError) => void; 24/** 25 * A `SQLTransaction` object is passed in as a parameter to the `callback` parameter for the 26 * `db.transaction()` method on a `Database` (see above). It allows enqueuing SQL statements to 27 * perform in a database transaction. 28 */ 29export interface SQLTransaction { 30 /** 31 * Enqueue a SQL statement to execute in the transaction. Authors are strongly recommended to make 32 * use of the `?` placeholder feature of the method to avoid against SQL injection attacks, and to 33 * never construct SQL statements on the fly. 34 * @param sqlStatement A string containing a database query to execute expressed as SQL. The string 35 * may contain `?` placeholders, with values to be substituted listed in the `arguments` parameter. 36 * @param args An array of values (numbers or strings) to substitute for `?` placeholders in the 37 * SQL statement. 38 * @param callback Called when the query is successfully completed during the transaction. Takes 39 * two parameters: the transaction itself, and a `ResultSet` object (see below) with the results 40 * of the query. 41 * @param errorCallback Called if an error occurred executing this particular query in the 42 * transaction. Takes two parameters: the transaction itself, and the error object. 43 */ 44 executeSql(sqlStatement: string, args?: (number | string)[], callback?: SQLStatementCallback, errorCallback?: SQLStatementErrorCallback): void; 45} 46export declare type SQLStatementCallback = (transaction: SQLTransaction, resultSet: SQLResultSet) => void; 47export declare type SQLStatementErrorCallback = (transaction: SQLTransaction, error: SQLError) => boolean; 48export declare type SQLResultSet = { 49 /** 50 * The row ID of the row that the SQL statement inserted into the database, if a row was inserted. 51 */ 52 insertId?: number; 53 /** 54 * The number of rows that were changed by the SQL statement. 55 */ 56 rowsAffected: number; 57 rows: SQLResultSetRowList; 58}; 59export interface SQLResultSetRowList { 60 /** 61 * The number of rows returned by the query. 62 */ 63 length: number; 64 /** 65 * Returns the row with the given `index`. If there is no such row, returns `null`. 66 * @param index Index of row to get. 67 */ 68 item(index: number): any; 69 /** 70 * The actual array of rows returned by the query. Can be used directly instead of 71 * getting rows through rows.item(). 72 */ 73 _array: any[]; 74} 75export declare class SQLError { 76 static UNKNOWN_ERR: number; 77 static DATABASE_ERR: number; 78 static VERSION_ERR: number; 79 static TOO_LARGE_ERR: number; 80 static QUOTA_ERR: number; 81 static SYNTAX_ERR: number; 82 static CONSTRAINT_ERR: number; 83 static TIMEOUT_ERR: number; 84 code: number; 85 message: string; 86} 87export interface WebSQLDatabase extends Database { 88 exec(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void; 89 /** 90 * Close the database. 91 */ 92 closeAsync(): void; 93 /** 94 * Delete the database file. 95 * > The database has to be closed prior to deletion. 96 */ 97 deleteAsync(): Promise<void>; 98} 99export declare type Query = { 100 sql: string; 101 args: unknown[]; 102}; 103export declare type ResultSetError = { 104 error: Error; 105}; 106/** 107 * `ResultSet` objects are returned through second parameter of the `success` callback for the 108 * `tx.executeSql()` method on a `SQLTransaction` (see above). 109 */ 110export declare type ResultSet = { 111 /** 112 * The row ID of the row that the SQL statement inserted into the database, if a row was inserted. 113 */ 114 insertId?: number; 115 /** 116 * The number of rows that were changed by the SQL statement. 117 */ 118 rowsAffected: number; 119 rows: { 120 [column: string]: any; 121 }[]; 122}; 123export declare type SQLiteCallback = (error?: Error | null, resultSet?: (ResultSetError | ResultSet)[]) => void; 124//# sourceMappingURL=SQLite.types.d.ts.map