Class: DbManager<S, C>
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.
Type Parameters
Type Parameter |
---|
S extends Schema |
C extends Config |
Constructors
Constructor
new DbManager<
S
,C
>(schema
,c
,rootUrl
):DbManager
<S
,C
>
Parameters
Parameter | Type |
---|---|
schema | S |
c | C |
rootUrl | string |
Returns
DbManager
<S
, C
>
Methods
connect()
connect(
options?
):symbol
Creates a "connection" to a database.
If onDisk is true, the database will be created on disk, in a "data" folder, with the name of the current environment. If onDisk is a string, the database will be created at the given (absolute) path.
Parameters
Parameter | Type |
---|---|
options? | DbOptions |
Returns
symbol
disconnect()
disconnect(
key
):boolean
Parameters
Parameter | Type |
---|---|
key | symbol |
Returns
boolean
get()
get(
key
):undefined
|DbConnection
<S
>
Parameters
Parameter | Type |
---|---|
key | symbol |
Returns
undefined
| DbConnection
<S
>
publicInterface()
publicInterface():
object
Returns
connect()
connect: (
options?
) =>symbol
Creates a "connection" to a database.
If onDisk is true, the database will be created on disk, in a "data" folder, with the name of the current environment. If onDisk is a string, the database will be created at the given (absolute) path.
Parameters
Parameter | Type |
---|---|
options? | DbOptions |
Returns
symbol
disconnect()
disconnect: (
key
) =>boolean
Parameters
Parameter | Type |
---|---|
key | symbol |
Returns
boolean