New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

mysql-all

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

mysql-all

An easy way to connect to multiple mysql databases

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
5
Maintainers
1
Weekly downloads
 
Created
Source

mysql-all

An easy way to connect to multiple mysql databases in one shot.

Build Status Coverage Status

Usage.

To use in your project, just execute

npm install mysql-all --save

This will download mysql-all as well as add it as a dependency to your package.json.

Then require mysql-all in your code:

var mysqlAll = require('mysql-all');

//pass in your connections object and return option
var connections = mysqlAll(connections, option);
connections is mandatory and must be an array or object/json.
option is the return type and it is optional.
If option is not specified or specified option is neither "array"
nor "object" return type will be defaulted to object.

Usecases:

For our example usescases, we will use

  • arrayConfigs as array of our connections
  • objectConfigs as object who's members are our connections
var arrayConfigs = [
    {
        host     : 'localhost',
        user     : 'me',
        password : 'secret',
        database : 'my_db1'
    },
    {
        host     : 'somehost',
        user     : 'someone',
        password : 'secret',
        database : 'my_db2'
    },
    {
        host     : 'anotherhost',
        user     : 'you',
        password : 'secret',
        database : 'my_db2'
    },
];

var objectConfigs = {
    financedb:{
        host     : 'localhost',
        user     : 'me',
        password : 'secret',
        database : 'my_db1'
    },
    hrdb:{
        host     : 'anotherhost',
        user     : 'you',
        password : 'secret',
        database : 'my_db2'
    }
};

Usecase 1: Array of connections and return type specified as "array".

var connections = require('mysql-all')(arrayConfigs, 'array');

//output connections
[conn1, conn2, conn3]

Usecase 2: Array of connections and return type specified as "object".

var connections = require('mysql-all')(arrayConfigs, 'object');

//outputs an object of connections with host+database name as keys:
{
    localhostmy_db1: 'connection to localhost',
    somehostmy_db2: 'connection to somehost',
    anotherhostmy_db2: 'connection to anotherhost'
}

Usecase 3: Array of connections and return type specified as "object".

var connections = require('mysql-all')(arrayConfigs);

//outputs an object of connections with host+database name as keys:
{
    localhostmy_db1: 'connection to localhost',
    somehostmy_db2: 'connection to somehost',
    anotherhostmy_db2: 'connection to anotherhost'
}

//NOTE: this yields same result as usecase 2

Usecase 4: Object of connections and return type specified as "array".

var connections = require('mysql-all')(objectConfigs, 'array');

//output connections
[conn1, conn2]

//NOTE: this yields similar result as usecase 1

Usecase 5: Object of connections and return type specified as "object".

var connections = require('mysql-all')(objectConfigs, 'object');

//output connections
{
    financedb: 'connection to finance db',
    hrdb: 'connection to hr db'
}

//NOTE: this yields similar result as usecase 3
//except that in this case the keys in the output object will be same as the
// keys in the input connection object/json (objectConfigs) //object/JSON.

//Also not that if 'object' was not specified i.e: require('mysql-all')(objectConfigs);
// output will be same since mysql-all defaults to object when no return option is specified.

Valid connections input types.

  • Array.

  • Object literals and

  • JSON.

OK, Go mysql-all!!

Keywords

mysql

FAQs

Package last updated on 02 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