database
const database: { list: Promise<string[]>; describe: Promise<DatabaseTableDescription>; query: Promise<DatabaseQueryResult>;};Defined in: domains/database.ts:79
Type Declaration
Section titled “Type Declaration”list()
Section titled “list()”list(): Promise<string[]>;List the SQLite database files available to the current presentation.
Returns
Section titled “Returns”Promise<string[]>
Array of database file path strings.
Remarks
Section titled “Remarks”Returns an empty array outside the Mobile Locker app.
Throws
Section titled “Throws”MobileLockerDatabaseError on network failure or server error.
describe()
Section titled “describe()”describe(database, table): Promise<DatabaseTableDescription>;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
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
database |
string |
Path to the .sqlite file (relative to the presentation root). |
table |
string |
Name of the table to inspect. |
Returns
Section titled “Returns”Promise<DatabaseTableDescription>
A DatabaseTableDescription with name, sql, and columns.
Throws
Section titled “Throws”MobileLockerDatabaseError with code InvalidPath if the table does not exist.
Example
Section titled “Example”const schema = await mobilelocker.database.describe('data/products.sqlite', 'products')console.log(schema.columns.map(c => c.name))query()
Section titled “query()”query( path, sql,parameters?): Promise<DatabaseQueryResult>;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
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
path |
string |
undefined |
Path to the .sqlite file (relative to the presentation root). |
sql |
string |
undefined |
A SQL SELECT statement, optionally with ? or :name placeholders. |
parameters |
Record<string, unknown> | unknown[] |
[] |
Positional array or named object of bind parameters. |
Returns
Section titled “Returns”Promise<DatabaseQueryResult>
A DatabaseQueryResult with rows, rows_affected, and last_insert_row_id.
Throws
Section titled “Throws”MobileLockerDatabaseError with codes InvalidPath, WriteNotPermitted,
NotReady, QueryFailed, or NotConnected.
Example
Section titled “Example”const result = await mobilelocker.database.query( 'data/products.sqlite', 'SELECT * FROM products WHERE category = ?', ['widgets'])result.rows.forEach(row => console.log(row.name))