2014-09-01 17:18:45 +02:00
|
|
|
'use strict';
|
|
|
|
|
2014-04-08 16:25:57 -04:00
|
|
|
// SQLite3
|
|
|
|
// -------
|
2015-04-19 16:31:52 -04:00
|
|
|
var Promise = require('../../promise');
|
2014-04-08 16:25:57 -04:00
|
|
|
|
2015-04-19 16:31:52 -04:00
|
|
|
var inherits = require('inherits');
|
|
|
|
var Client = require('../../client');
|
|
|
|
var Runner = require('./runner');
|
|
|
|
var QueryCompiler = require('./query/compiler')
|
|
|
|
var assign = require('lodash/object/assign');
|
2014-04-08 16:25:57 -04:00
|
|
|
|
|
|
|
function Client_SQLite3(config) {
|
2015-04-19 16:31:52 -04:00
|
|
|
Client.call(this, config)
|
2014-04-08 16:25:57 -04:00
|
|
|
}
|
2015-04-19 16:31:52 -04:00
|
|
|
inherits(Client_SQLite3, Client)
|
2014-04-08 16:25:57 -04:00
|
|
|
|
2015-04-19 16:31:52 -04:00
|
|
|
assign(Client_SQLite3.prototype, {
|
2014-04-08 16:25:57 -04:00
|
|
|
|
2015-04-19 16:31:52 -04:00
|
|
|
dialect: 'sqlite3',
|
2014-04-08 16:25:57 -04:00
|
|
|
|
2015-04-19 16:31:52 -04:00
|
|
|
moduleName: 'sqlite3',
|
2014-07-03 11:59:29 +02:00
|
|
|
|
2015-04-19 16:31:52 -04:00
|
|
|
Runner: Runner,
|
2014-04-08 16:25:57 -04:00
|
|
|
|
2015-04-19 16:31:52 -04:00
|
|
|
QueryCompiler: QueryCompiler,
|
2014-04-16 01:23:50 -04:00
|
|
|
|
2015-04-19 16:31:52 -04:00
|
|
|
// Get a raw connection from the database, returning a promise with the connection object.
|
|
|
|
acquireRawConnection: function() {
|
|
|
|
var driver = this;
|
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
|
var db = new sqlite3.Database(driver.connectionSettings.filename, function(err) {
|
|
|
|
if (err) return reject(err);
|
|
|
|
resolve(db);
|
|
|
|
});
|
2014-04-08 16:25:57 -04:00
|
|
|
});
|
2015-04-19 16:31:52 -04:00
|
|
|
},
|
2014-04-08 16:25:57 -04:00
|
|
|
|
2015-04-19 16:31:52 -04:00
|
|
|
// Used to explicitly close a connection, called internally by the pool
|
|
|
|
// when a connection times out or the pool is shutdown.
|
|
|
|
destroyRawConnection: function(connection, cb) {
|
|
|
|
connection.close();
|
|
|
|
cb()
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
2014-04-08 16:25:57 -04:00
|
|
|
|
|
|
|
module.exports = Client_SQLite3;
|