xref: /expo/packages/expo-sqlite/build/SQLite.d.ts (revision 4bf00a55)
1import './polyfillNextTick';
2import type { Query, ResultSet, ResultSetError, SQLiteCallback, SQLTransactionAsyncCallback, SQLTransactionAsync, SQLTransactionCallback, SQLTransactionErrorCallback } from './SQLite.types';
3/** The database returned by `openDatabase()` */
4export declare class SQLiteDatabase {
5    _name: string;
6    _closed: boolean;
7    constructor(name: string);
8    /**
9     * Executes the SQL statement and returns a callback resolving with the result.
10     */
11    exec(queries: Query[], readOnly: boolean, callback: SQLiteCallback): void;
12    /**
13     * Executes the SQL statement and returns a Promise resolving with the result.
14     */
15    execAsync(queries: Query[], readOnly: boolean): Promise<(ResultSetError | ResultSet)[]>;
16    /**
17     * @deprecated Use `closeAsync()` instead.
18     */
19    close: () => Promise<void>;
20    /**
21     * Close the database.
22     */
23    closeAsync(): Promise<void>;
24    /**
25     * Synchronously closes the database.
26     */
27    closeSync(): void;
28    /**
29     * Delete the database file.
30     * > The database has to be closed prior to deletion.
31     */
32    deleteAsync(): Promise<void>;
33    onDatabaseChange(cb: (result: {
34        tableName: string;
35        rowId: number;
36    }) => void): import("expo-modules-core").Subscription;
37    /**
38     * Creates a new transaction with Promise support.
39     * @param asyncCallback A `SQLTransactionAsyncCallback` function that can perform SQL statements in a transaction.
40     * @param readOnly true if all the SQL statements in the callback are read only.
41     */
42    transactionAsync(asyncCallback: SQLTransactionAsyncCallback, readOnly?: boolean): Promise<void>;
43    version: string;
44    /**
45     * Execute a database transaction.
46     * @param callback A function representing the transaction to perform. Takes a Transaction
47     * (see below) as its only parameter, on which it can add SQL statements to execute.
48     * @param errorCallback Called if an error occurred processing this transaction. Takes a single
49     * parameter describing the error.
50     * @param successCallback Called when the transaction has completed executing on the database.
51     */
52    transaction(callback: SQLTransactionCallback, errorCallback?: SQLTransactionErrorCallback, successCallback?: () => void): void;
53    readTransaction(callback: SQLTransactionCallback, errorCallback?: SQLTransactionErrorCallback, successCallback?: () => void): void;
54}
55/**
56 * Open a database, creating it if it doesn't exist, and return a `Database` object. On disk,
57 * the database will be created under the app's [documents directory](./filesystem), i.e.
58 * `${FileSystem.documentDirectory}/SQLite/${name}`.
59 * > The `version`, `description` and `size` arguments are ignored, but are accepted by the function
60 * for compatibility with the WebSQL specification.
61 * @param name Name of the database file to open.
62 * @param version
63 * @param description
64 * @param size
65 * @param callback
66 * @return
67 */
68export declare function openDatabase(name: string, version?: string, description?: string, size?: number, callback?: (db: SQLiteDatabase) => void): SQLiteDatabase;
69/**
70 * Internal data structure for the async transaction API.
71 * @internal
72 */
73export declare class ExpoSQLTransactionAsync implements SQLTransactionAsync {
74    private readonly db;
75    private readonly readOnly;
76    constructor(db: SQLiteDatabase, readOnly: boolean);
77    executeSqlAsync(sqlStatement: string, args?: (number | string)[]): Promise<ResultSetError | ResultSet>;
78}
79//# sourceMappingURL=SQLite.d.ts.map