Database

Note: This won't do anything for you if you're not using a StorageProvider for your client that uses Sequelize

Holds the Sequelize connection to whichever database backend is chosen via the Client StorageProvider. As long as you wait until clientReady you can safely use Database.instance to get the Database instance and access the Sequelize connection via Database#db

This will allow you to define and access your own Sequelize Models without having to create another database connection. This is especially important when using SQLiteProvider as SQLite does not like having multiple connections to an sqlite file

Constructor

new Database()

Source:

Properties

.db: Sequelize

(Static) The Sequelize connection to the database specified by your chosen storage provider.

WARNING: Accessing this before the client has created the singleton instance will throw an error. To be safe, wait until clientReady before accessing the Database connection

Type:
Sequelize
Source:

.db: Sequelize

The Sequelize connection to the database specified by your chosen storage provider

Type:
Sequelize
Source:

Methods

(static) .instance(url?: string, debug?: boolean)Database

As long as a Sequelize-using storage provider is being used, this will return the Database instance holding the Sequelize connection to the database.

Parameters are not needed and will be passed internally by the framework when the Database singleton is created before clientReady is emitted.

WARNING: Accessing this before the client has created the singleton instance will throw an error. To be safe, wait until clientReady before accessing the Database connection

Parameters:
Name Type Attributes Default Description
url
string
<optional>

The database connection url

debug
boolean
<optional>
false

Whether or not to log Database debug info

Source:
Returns:
Database

.init() → Promise<void>

Authenticate the connection to the database. This is called internally by the framework

Source:
Returns:
Promise<void>