{"size": 1374, "ext": "js", "max_stars_repo_path": "index.js", "max_stars_repo_name": "mlaanderson/database-js-adodb", "max_stars_repo_stars_event_min_datetime": "2017-12-07T21:07:06.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-21T17:14:59.000Z", "max_issues_repo_path": "index.js", "max_issues_repo_name": "mlaanderson/database-js-adodb", "max_issues_repo_issues_event_min_datetime": "2018-09-05T08:01:05.000Z", "max_issues_repo_issues_event_max_datetime": "2020-11-26T19:37:39.000Z", "max_forks_repo_path": "index.js", "max_forks_repo_name": "mlaanderson/database-js-adodb", "max_forks_repo_forks_event_min_datetime": "2017-12-07T21:30:46.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-17T23:28:29.000Z"}
{"max_stars_count": 3, "max_issues_count": 2, "max_forks_count": 4, "avg_line_length": 25.4444444444, "max_line_length": 197, "alphanum_fraction": 0.6040756914}
var ADODB = require('node-adodb');

class ADODB_Promise_Connection {
    constructor(connection) {
        this.__connection = connection;
    }

    /**
     * Runs the passed SQL as a query.
     * 
     * @param {string} sql 
     * @returns {Promise<array>}
     * @memberof ADODB_Promise_Connection
     */
    query(sql) {
        var self = this;
        return self.__connection.query(sql);
    }

    /**
     * Executes the passed SQL
     * 
     * @param {string} sql 
     * @param {any} scalar 
     * @returns {Promise<any>}
     * @memberof ADODB_Promise_Connection
     */
    execute(sql, scalar) {
        var self = this;
        return self.__connection.execute(sql, scalar);
    }

    /**
     * Does nothing, required for database-js
     * 
     * @returns {Promise<boolean>}
     * @memberof ADODB_Promise_Connection
     */
    close() {
        return Promise.resolve(true);
    }
}

module.exports = {
    /**
     * @param {ConnectionObject}
     * @returns {ADODB_Promise_Connection}
     */
    open: function(connection_parameters) {
        var connection_string = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + connection_parameters.Database + ";" + (connection_parameters.Parameters ? connection_parameters.Parameters : '' );
        var base = ADODB.open(connection_string);
        return new ADODB_Promise_Connection(base);
    }
};