xref: /expo/packages/expo-sqlite/build/SQLite.d.ts (revision df35d4e9)
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    /**
34     * Creates a new transaction with Promise support.
35     * @param asyncCallback A `SQLTransactionAsyncCallback` function that can perform SQL statements in a transaction.
36     * @param readOnly true if all the SQL statements in the callback are read only.
37     */
38    transactionAsync(asyncCallback: SQLTransactionAsyncCallback, readOnly?: boolean): Promise<void>;
39    version: string;
40    /**
41     * Execute a database transaction.
42     * @param callback A function representing the transaction to perform. Takes a Transaction
43     * (see below) as its only parameter, on which it can add SQL statements to execute.
44     * @param errorCallback Called if an error occurred processing this transaction. Takes a single
45     * parameter describing the error.
46     * @param successCallback Called when the transaction has completed executing on the database.
47     */
48    transaction(callback: SQLTransactionCallback, errorCallback?: SQLTransactionErrorCallback, successCallback?: () => void): void;
49    readTransaction(callback: SQLTransactionCallback, errorCallback?: SQLTransactionErrorCallback, successCallback?: () => void): void;
50}
51/**
52 * Open a database, creating it if it doesn't exist, and return a `Database` object. On disk,
53 * the database will be created under the app's [documents directory](./filesystem), i.e.
54 * `${FileSystem.documentDirectory}/SQLite/${name}`.
55 * > The `version`, `description` and `size` arguments are ignored, but are accepted by the function
56 * for compatibility with the WebSQL specification.
57 * @param name Name of the database file to open.
58 * @param version
59 * @param description
60 * @param size
61 * @param callback
62 * @return
63 */
64export declare function openDatabase(name: string, version?: string, description?: string, size?: number, callback?: (db: SQLiteDatabase) => void): SQLiteDatabase;
65/**
66 * Internal data structure for the async transaction API.
67 * @internal
68 */
69export declare class ExpoSQLTransactionAsync implements SQLTransactionAsync {
70    private readonly db;
71    private readonly readOnly;
72    constructor(db: SQLiteDatabase, readOnly: boolean);
73    executeSqlAsync(sqlStatement: string, args?: (number | string)[]): Promise<ResultSetError | ResultSet>;
74}
75//# sourceMappingURL=SQLite.d.ts.map