-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
54 lines (49 loc) · 1.34 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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);
}
};