Skip to content

@saflib/drizzle-sqlite3


@saflib/drizzle-sqlite3

Classes

ClassDescription
DbManagerA class which mainly manages "connections" to the sqlite3 database and drizzle ORM. Any package which depends on this will create a single instance given the database schema and config, export the public interface, and be used by queries to access the drizzle ORM. This way the package which depends on @saflib/drizzle-sqlite3 has full access to its database, but packages which depend on it only have access to an opaque key which only database queries can use.
HandledDatabaseErrorA subclass of Error which is used to indicate that an error was caught and handled by the database library. Database packages should subclass this error, and these are not necessarily considered bugs if they occur.
UnhandledDatabaseErrorA subclass of Error which is used to indicate that an error was not caught and handled by the database library. The cause of the error is not propagated, since consumers of the database libary should not have access to underlying SQL issues.

Interfaces

InterfaceDescription
DbOptionsWhen a "connection" is created, these parameters are provided.

Type Aliases

Type AliasDescription
DbConnectionThe result of calling drizzle, typed to the schema you connected to.
DbKeyA symbol returned when connecting to the database. This key should be provided to any queries used by the consumer of the package. This is the only way a database consumer may interact with the database.
DbTransactionConvenience type; the tx object passed to the drizzle transaction callback, with a generic parameter for the schema.
SchemaCurrently this package expects the schema to be an object where some values are the result of sqliteTable calls. Organize your schema in this fashion when creating your DbManager and such.
TransactionCallbackConvenience type; the first parameter of the transaction method, with a generic parameter for the schema.

Functions

FunctionDescription
queryWrapperAll queries should use this wrapper. It will catch and obfuscate unhandled errors, and rethrow handled errors, though really handled errors should be returned, not thrown.