Connecting to a database

patio.createConnection

When using patio.createConnection to connect a database there are two types of parameters you can use.

Connetion URI

This is a well formed URI that will be used to connect to the database.

Currently supported databases

Query options

Note: All other options will be passed to the underlying driver see the driver documentation for additional options.

//Create a connection to a mysql database at localhost port 3306, with the username test, password test and
// 1 connection by default and a max of 10
var DB = patio.createConnection("mysql://test:testpass@localhost:3306/test?maxConnections=1&minConnections=10");

Connection Object

This is an object to used to connect.

Currently supported databases

Options

Note: All other options will be passed to the underlying driver see the driver documentation for additional options.

//connect using an object
var DB = patio.createConnection({
             host : "localhost",
             port : 3306,
             type : "mysql",
             maxConnections : 10,
             minConnections : 1,
             user : "test",
             password : "testpass",
             database : 'test'
});
    //Create a connection to a mysql database at localhost port 3306, with the username test, password test and
    // 1 connection by default and a max of 10

Disconnecting

To disconnect from a database you can use:

patio.disconnect().chain(function(){
    //all databases are disconnected all queued queries have finished
});
DB.disconnect().chain(function(){
    //database is disconnected and all queued queries have finished
});

Documentation generated using coddoc.