-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
55 lines (47 loc) · 1.07 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
55
/*!
* edge-oledb
* Copyright(c) 2015 Brian Taber
* MIT Licensed
*/
"use strict";
/**
* Module dependencies.
* @private
*/
var util = require('util');
var edge = require('edge');
var adodb = edge.func(__dirname + '/lib/oledb.cs');
/**
* Module exports.
*/
module.exports = nodeEdgeOledb
/**
* Perform adodb query via edge and c#
*
* @param {object} options
* @param {function} callback
* @public
*/
function nodeEdgeOledb(options, callback){
if (!(this instanceof nodeEdgeOledb)) return new nodeEdgeOledb(options, callback);
adodb(options, function(error, result){
var data = {}
if (error){
data.valid = false
data.error = error.message
if (error && error.hasOwnProperty('InnerException')){
if (error.InnerException && error.InnerException.hasOwnProperty('Message')){
data.errorMessage = error.InnerException.Message
}else{
data.errorMessage = util.inspect(error.InnerException)
}
}else{
data.errorMessage = util.inspect(error);
}
}else{
data.valid = true
data.records = result
}
setImmediate(callback, data);
});
}