Mobile Locker JavaScript SDK
    Preparing search index...

    Variable databaseConst

    database: {
        list(): Promise<string[]>;
        describe(
            database: string,
            table: string,
        ): Promise<DatabaseTableDescription>;
        query(
            path: string,
            sql: string,
            parameters?: Record<string, unknown> | unknown[],
        ): Promise<DatabaseQueryResult>;
    } = ...

    Type Declaration

    • list: function
      • List the SQLite database files available to the current presentation.

        Returns Promise<string[]>

        Array of database file path strings.

        Returns an empty array outside the Mobile Locker app.

        MobileLockerDatabaseError on network failure or server error.

    • describe: function
      • Describe the schema of a table in a SQLite database.

        In local development, falls back to sql.js and reads the schema directly from the database file via PRAGMA table_info.

        Parameters

        • database: string

          Path to the .sqlite file (relative to the presentation root).

        • table: string

          Name of the table to inspect.

        Returns Promise<DatabaseTableDescription>

        A DatabaseTableDescription with name, sql, and columns.

        MobileLockerDatabaseError with code InvalidPath if the table does not exist.

        const schema = await mobilelocker.database.describe('data/products.sqlite', 'products')
        console.log(schema.columns.map(c => c.name))
    • query: function
      • Execute a SQL SELECT query against a SQLite database embedded in the presentation.

        In local development, falls back to sql.js and fetches the database file directly. Only SELECT statements are permitted — write operations throw WriteNotPermitted.

        Parameters

        • path: string

          Path to the .sqlite file (relative to the presentation root).

        • sql: string

          A SQL SELECT statement, optionally with ? or :name placeholders.

        • parameters: Record<string, unknown> | unknown[] = []

          Positional array or named object of bind parameters.

        Returns Promise<DatabaseQueryResult>

        A DatabaseQueryResult with rows, rows_affected, and last_insert_row_id.

        MobileLockerDatabaseError with codes InvalidPath, WriteNotPermitted, NotReady, QueryFailed, or NotConnected.

        const result = await mobilelocker.database.query(
        'data/products.sqlite',
        'SELECT * FROM products WHERE category = ?',
        ['widgets']
        )
        result.rows.forEach(row => console.log(row.name))