@saflib/drizzle-sqlite3
@saflib/drizzle-sqlite3
Classes
Class | Description |
---|---|
DbManager | A 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. |
HandledDatabaseError | A 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. |
UnhandledDatabaseError | A 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
Interface | Description |
---|---|
DbOptions | When a "connection" is created, these parameters are provided. |
Type Aliases
Type Alias | Description |
---|---|
DbConnection | The result of calling drizzle , typed to the schema you connected to. |
DbKey | A 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. |
DbTransaction | Convenience type; the tx object passed to the drizzle transaction callback, with a generic parameter for the schema. |
Schema | Currently 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. |
TransactionCallback | Convenience type; the first parameter of the transaction method, with a generic parameter for the schema. |
Functions
Function | Description |
---|---|
queryWrapper | All 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. |