The full database backend port: lifecycle plus data access.
This is the seam an application implements to plug a database the framework
does not ship an adapter for, and hand it to
DatabasePlugin({ type: 'custom', adapter }). It lives in common rather
than inside the database plugin precisely so a backend can be written in
another package — cloudflare-plugin's D1Adapter is the first.
migrate() is deliberately absent: programmatic migration is not honestly
implementable across the supported backends, and every one of them owns
migrations through its own CLI.
Example 1
Example 1
class MyAdapter implements IDatabaseAdapter { connect(): Promise<void> { return Promise.resolve(); } disconnect(): Promise<void> { return Promise.resolve(); } isReady(): boolean { return true; } createDataSource(entity: string): IDataSource { return makeSource(entity); } transactionIsolationLevels = ['serializable'] as const; beginTransaction(options?: TransactionOptions): Promise<IAdapterTransaction> { return openTx(options); } rawQuery<T>(sql: string, params?: unknown[]): Promise<T[]> { return run(sql, params); } }
createDataSource(entity: string): IDataSource
Open a non-transactional data source for the named entity.
beginTransaction(options?: TransactionOptions): Promise<IAdapterTransaction>
Begin a transaction, returning a handle that can open transaction-scoped data sources as well as commit and roll back.