UNPKG

sql-client

Version:

A dirt-simple SQL client abstraction (currently) supporting PostgreSQL, MySQL and SQLite.

49 lines (40 loc) 1.69 kB
// Generated by CoffeeScript 2.6.0 (function() { var ConnectionFactory, splice = [].splice; ConnectionFactory = class ConnectionFactory { constructor() { this.open_connection = this.open_connection.bind(this); this.close_connection = this.close_connection.bind(this); this.execute = this.execute.bind(this); this.pre_process_sql = this.pre_process_sql.bind(this); } open_connection(...options) { var callback, ref; ref = options, [...options] = ref, [callback] = splice.call(options, -1); return typeof callback === "function" ? callback(new Error("open_connection not implemented; please override")) : void 0; } close_connection(connection, callback) { if (typeof (connection != null ? connection.end : void 0) === 'function') { connection.end(); return typeof callback === "function" ? callback() : void 0; } else if (typeof (connection != null ? connection.close : void 0) === 'function') { connection.close(); return typeof callback === "function" ? callback() : void 0; } else { return typeof callback === "function" ? callback(new Error("close_connection not implemented; please override")) : void 0; } } execute(connection, sql, bindvars, callback) { if (typeof connection.query === 'function') { return connection.query(sql, bindvars, callback); } else { return callback(new Error("execute not implemented; please override")); } } pre_process_sql(sql, bindvars, callback) { return callback(null, sql, bindvars); } }; exports.ConnectionFactory = ConnectionFactory; }).call(this);