🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

app-context-mysql

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

app-context-mysql

mysql initializer for app-context

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
14
600%
Maintainers
1
Weekly downloads
 
Created
Source

app-context-mysql

mysql 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.exports = function() {
  this.runlevel('connected')
    // attach a connection to APP.mysql - use the value at APP.config.mysql as the connection string
    .use('mysql', '$mysql')

    // attach a connection to APP.mysql
    .use('mysql', 'mysql://localhost:3306/foobar')

    // attach a connection pool to APP.mysql
    .use('mysql', {url: 'mysql://localhost:3306/foobar', pool: true})

    // create 2 connections and attach them as an object to APP.mysql
    // this will create APP.mysql.users and APP.mysql.data
    .use('mysql', {
      users: '$mysql.users',
      data: '$mysql.data'
    })

    // you can also pass options to each connection
    .use('mysql', {
      users: {url: 'mysql://localhost:3306/users', pool: true},
      data: {url: 'mysql://localhost:3306/data', connectTimeout: 3000}
    })
};

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.

Keywords

app-context

FAQs

Package last updated on 25 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts