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