Creates a database with the given name and according to the given migrations and custom types.
See Example for example database construction.
The database name. Must be unique.
The database migrations as well as codecs for custom datatypes.
The database shorthand object.
An operation such as
await db.$.myStore.add(myitem)
Will add an item to the database store called myStore
.
Also see Example.
Resolves when the database is finished initializing.
When the database is created, it will immediately begin running migrations.
All database operations will wait for these migrations to finish before actually
taking the action. However, this means that before await
ing a database operation,
you are not guaranteed about the state of the database. Weird things can happen
if, say, you open a new database with the same name while an existing one is
still initializing.
If there is an issue when migrating, this value will never resolve, and an error will be printed into the console.
So, if you need to gaurantee that the database is initialized, but don't want to do any operations to do this, you can await this attribute.
The name of the database. Database names are unique.
The database version. This is an integer equal to the number of migrations given.
Create a Connection to a database and run some code.
This will create a new Connection to the database, run the given callback, and then close the connection once the callback has completed.
Create new connection to the database.
Unlike with Database.connect, connections created with this method must be manually closed via Connection.close.
Perform a Transaction on a database.
This will create a new [[Connection] to the database, create a new Transaction on that connection, run the given callback, close the transaction, and then close the connection once the callback has completed.
Generated using TypeDoc
A Jine Database.
The purpose of a Database is to store data. The data is organized into several item [[Stores]], which are queryable by Indexes. The shape of the database, i.e. what stores it contains and what indexes those contain, are defined during migrations.