Comparing version 0.1.8 to 0.1.9
@@ -23,17 +23,24 @@ var anyDB = require('any-db'); | ||
if (dialect == 'sqlite') { | ||
try { | ||
var sqlitepool = require('./sqlite-pool'); | ||
var pool = sqlitepool(opt.url, opt.connections); | ||
} catch (e) { | ||
throw new Error("Unable to load sqlite pool: " + e.message); | ||
var pool; | ||
var self = {}; | ||
self.open = function() { | ||
if (pool) | ||
return; // already open | ||
if (dialect == 'sqlite') { | ||
try { | ||
var sqlitepool = require('./sqlite-pool'); | ||
pool = sqlitepool(opt.url, opt.connections); | ||
} catch (e) { | ||
throw new Error("Unable to load sqlite pool: " + e.message); | ||
} | ||
} | ||
else { | ||
pool = anyDB.createPool(opt.url, opt.connections); | ||
} | ||
} | ||
else { | ||
var pool = anyDB.createPool(opt.url, opt.connections); | ||
} | ||
var self = {}; | ||
self.open(); | ||
function extendedTable(table) { | ||
@@ -105,3 +112,8 @@ // inherit everything from a regular table. | ||
self.close = pool.close.bind(pool); | ||
self.close = function() { | ||
if (pool) | ||
pool.close.apply(pool, arguments); | ||
pool = null; | ||
}; | ||
self.begin = pool.begin.bind(pool); | ||
@@ -108,0 +120,0 @@ self.query = pool.query.bind(pool); |
{ | ||
"name": "anydb-sql", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"description": "anydb-sql combines node-anydb and node-sql", | ||
@@ -5,0 +5,0 @@ "main": "anydb-sql.js", |
11206
236