AI Notice: Most documentation right now was auto-generated by an LLM. Handwritten documentation will be implemented over time on the road to 1.0
PluginDatabaseAPI
SQL database API for plugin-owned tables
Signature
interface PluginDatabaseAPI {
query<T = Record<string, unknown>>(sql: string, params?: unknown[]): Promise<T[]>;
execute(sql: string, params?: unknown[]): Promise<DatabaseExecuteResult>;
insert(table: string, data: Record<string, unknown>): Promise<number>;
update(table: string, data: Record<string, unknown>, where: string, params?: unknown[]): Promise<number>;
deleteFrom(table: string, where: string, params?: unknown[]): Promise<number>;
selectAll<T = Record<string, unknown>>(table: string, where?: string, params?: unknown[]): Promise<T[]>;
}Members
| Name | Type | Required | Description |
|---|---|---|---|
query | (sql: string, params?: unknown[]) => Promise<T[]> | yes | Execute a raw SQL query and return results. Table names in the query should use the short name (without prefix). |
execute | (sql: string, params?: unknown[]) => Promise<DatabaseExecuteResult> | yes | Execute a SQL statement (INSERT, UPDATE, DELETE, etc.) |
insert | (table: string, data: Record<string, unknown>) => Promise<number> | yes | Insert a row into a table |
update | (table: string, data: Record<string, unknown>, where: string, params?: unknown[]) => Promise<number> | yes | Update rows in a table |
deleteFrom | (table: string, where: string, params?: unknown[]) => Promise<number> | yes | Delete rows from a table |
selectAll | (table: string, where?: string, params?: unknown[]) => Promise<T[]> | yes | Select all rows from a table |