db-pool
Easily create a Postgres/MySQL connection pool (postgres only until I get MariaDB/MySQL working on my new Ubuntu 13.04 dev machine).
Behind the scenes it returns an any-db pool which can be used as described here.
Getting Started
Install the module with: npm install db-pool
Configuration
Create a config/database.js containing something like
exportsapp1 = defaults: driver: 'postgres' min: 5 max: 20 development: database: "development" username: "username" password: "pass" production: database: "production" username: "username" password: "pass" port: 9999 test: database: "test" username: "username" password: "pass" host: "some.hostname" min: 15 ; exportsapp1 = ... ...
Example
var db_pool = ; // Optionally specify an alternative config file (default is to use /config/database.js)db_pool; // Create the default pool (from app1) using NODE_ENV=development|test|productionvar test = db_pool; // Create a pool to a development databasevar dev = db_pool;var app1_dev = db_pool; // Create another pool to a different databasevar test = db_pool; // Show the known connections. Active ones have pool, connStr and merged default attributes.console; // Run a querydev
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
Release History
v0.1.0 Postgres supported
License
Copyright (c) 2013 Mark Selby
Licensed under the MIT license.