xref: /expo/packages/expo-sqlite/build/SQLite.d.ts (revision adae5ee7)
1import './polyfillNextTick';
2import type { Query, ResultSet, SQLiteCallback, SQLTransactionAsyncCallback, SQLTransactionAsync } 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<ResultSet[]>;
16    /**
17     * @deprecated Use `closeAsync()` instead.
18     */
19    close: () => void;
20    /**
21     * Close the database.
22     */
23    closeAsync(): void;
24    /**
25     * Delete the database file.
26     * > The database has to be closed prior to deletion.
27     */
28    deleteAsync(): Promise<void>;
29    /**
30     * Creates a new transaction with Promise support.
31     * @param asyncCallback A `SQLTransactionAsyncCallback` function that can perform SQL statements in a transaction.
32     * @param readOnly true if all the SQL statements in the callback are read only.
33     */
34    transactionAsync(asyncCallback: SQLTransactionAsyncCallback, readOnly?: boolean): Promise<void>;
35}
36/**
37 * Open a database, creating it if it doesn't exist, and return a `Database` object. On disk,
38 * the database will be created under the app's [documents directory](./filesystem), i.e.
39 * `${FileSystem.documentDirectory}/SQLite/${name}`.
40 * > The `version`, `description` and `size` arguments are ignored, but are accepted by the function
41 * for compatibility with the WebSQL specification.
42 * @param name Name of the database file to open.
43 * @param version
44 * @param description
45 * @param size
46 * @param callback
47 * @return
48 */
49export declare function openDatabase(name: string, version?: string, description?: string, size?: number, callback?: (db: SQLiteDatabase) => void): SQLiteDatabase;
50/**
51 * Internal data structure for the async transaction API.
52 * @internal
53 */
54export declare class ExpoSQLTransactionAsync implements SQLTransactionAsync {
55    private readonly db;
56    private readonly readOnly;
57    constructor(db: SQLiteDatabase, readOnly: boolean);
58    executeSqlAsync(sqlStatement: string, args?: (number | string)[]): Promise<ResultSet>;
59}
60//# sourceMappingURL=SQLite.d.ts.map