app-context-mysql2
mysql2 initializer for app-context
Usage
This initializer can be auto-installed by using it in your context file.
This initializer will attach the configured connections to APP.mysql
.
module { this // attach a connection to APP.mysql - use the value at APP.config.mysql as the connection string // attach a connection to APP.mysql // attach a connection pool to APP.mysql // create 2 connections and attach them as an object to APP.mysql // this will create APP.mysql.users and APP.mysql.data // you can also pass options to each connection };
Connection Configurations
Each connection can be configured with either a connection string (like mysql://localhost:3306/users
) or
with an object. The object will be passed through to the mysql constructor and can consist of any options
from connection options. There is a special url
option not listed that this initializer will parse and fill in for you (like the user, password, host, and port).
Connection Pooling
You can make any connection a pool by adding {pool: true}
to the configuration. Other options from the
configuration will be passed through to the mysql driver. You can see the available options at connection options and pool options.