Skip to content

Commit

Permalink
update to version 1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nuintun committed May 19, 2015
1 parent 6c50648 commit 3612328
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 20 deletions.
13 changes: 10 additions & 3 deletions examples/execute.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
/**
* Created by Newton on 2014/4/2.
*/
var ADODB = require('../lib/client'),
connection = ADODB.open('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=node-adodb.mdb;');

'use strict';

// External lib
var ADODB = require('../'),
colors = require('colors/safe');

// Variable declaration
var connection = ADODB.open('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=node-adodb.mdb;');

ADODB.debug = true;

connection
.execute('INSERT INTO Users(UserName, UserSex, UserAge) VALUES ("Newton", "Male", 25)')
.on('done', function (data){
console.log('Result:'.green.bold, JSON.stringify(data, null, ' ').bold);
console.log(colors.green.bold('Result:'), colors.bold(JSON.stringify(data, null, ' ')));
});
13 changes: 10 additions & 3 deletions examples/executeScalar.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
/**
* Created by Newton on 2014/4/2.
*/
var ADODB = require('../lib/client'),
connection = ADODB.open('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=node-adodb.mdb;');

'use strict';

// External lib
var ADODB = require('../'),
colors = require('colors/safe');

// Variable declaration
var connection = ADODB.open('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=node-adodb.mdb;');

ADODB.debug = true;

connection
.executeScalar('INSERT INTO Users(UserName, UserSex, UserAge) VALUES ("Newton", "Male", 25)', 'SELECT @@Identity AS id')
.on('done', function (data){
console.log('Result:'.green.bold, JSON.stringify(data, null, ' ').bold);
console.log(colors.green.bold('Result:'), colors.bold(JSON.stringify(data, null, ' ')));
});
13 changes: 10 additions & 3 deletions examples/query.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
/**
* Created by Newton on 2014/4/2.
*/
var ADODB = require('../lib/client'),
connection = ADODB.open('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=node-adodb.mdb;');

'use strict';

// External lib
var ADODB = require('../'),
colors = require('colors/safe');

// Variable declaration
var connection = ADODB.open('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=node-adodb.mdb;');

ADODB.debug = true;

connection
.query('SELECT * FROM Users')
.on('done', function (data){
console.log('Result:'.green.bold, JSON.stringify(data, null, ' ').bold);
console.log(colors.green.bold('Result:'), colors.bold(JSON.stringify(data, null, ' ')));
});
1 change: 1 addition & 0 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

'use strict';

// External lib
var config = require('./config'),
Execute = require('./execute'),
Query = require('./query'),
Expand Down
1 change: 1 addition & 0 deletions lib/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

'use strict';

// External lib
var util = require('util'),
proxy = require('./proxy'),
eventemitter = require('events').EventEmitter;
Expand Down
1 change: 1 addition & 0 deletions lib/executeScalar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

'use strict';

// External lib
var util = require('util'),
proxy = require('./proxy'),
eventemitter = require('events').EventEmitter;
Expand Down
18 changes: 10 additions & 8 deletions lib/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

'use strict';

require('colors');

// External lib
var fs = require('fs'),
path = require('path'),
config = require('./config'),
colors = require('colors/safe'),
iconv = require('iconv-lite'),
spawn = require('child_process').spawn,
adodb = path.join(__dirname, 'adodb.js'),
spawn = require('child_process').spawn;

// Variable declaration
var adodb = path.join(__dirname, 'adodb.js'),
sysroot = process.env['systemroot'] || process.env['windir'],
x64 = fs.existsSync(path.join(sysroot, 'SysWOW64')),
cscript = path.join(sysroot, x64 ? 'SysWOW64' : 'System32', 'cscript.exe');
Expand Down Expand Up @@ -39,8 +41,8 @@ exports.exec = function (method, params, done, fail, encoding){
// Set encoding
encoding = isString(encoding) && encoding.trim() ? encoding : config.encoding;

config.debug && console.log('Exec:'.green.bold, method.cyan.bold);
config.debug && console.log('Params:'.green.bold, JSON.stringify(params, null, ' ').cyan.bold);
config.debug && console.log(colors.green.bold('Exec:'), colors.cyan.bold(method));
config.debug && console.log(colors.green.bold('Params:'), colors.cyan.bold(JSON.stringify(params, null, ' ')));

// Params encode to base64
params = (new Buffer(JSON.stringify(params))).toString('base64');
Expand Down Expand Up @@ -68,12 +70,12 @@ exports.exec = function (method, params, done, fail, encoding){
message: (data instanceof Buffer ? iconv.decode(data, encoding) : data).replace(/\r\n/img, '')
};

config.debug && console.log('Error:'.red.bold, JSON.stringify(data, null, ' ').cyan.bold);
config.debug && console.log(colors.yellow.bold('Error:'), colors.red.bold(JSON.stringify(data, null, ' ')));
fail(data);
});

// Exec error
stdio.on('error', function (error){
console.log('Exec Error:'.red.bold, JSON.stringify(error, null, ' ').cyan.bold);
console.log(colors.yellow.bold('Exec Error:'), colors.red.bold(JSON.stringify(error, null, ' ')));
});
};
1 change: 1 addition & 0 deletions lib/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

'use strict';

// External lib
var util = require('util'),
proxy = require('./proxy'),
eventemitter = require('events').EventEmitter;
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-adodb",
"version": "1.3.0",
"version": "1.3.1",
"main": "index.js",
"license": "MIT",
"keywords": [
Expand Down Expand Up @@ -29,8 +29,8 @@
"url": "https://github.com/nuintun/node-adodb.git"
},
"dependencies": {
"iconv-lite": "~0.4.8",
"colors": "~1.0.3"
"iconv-lite": "^0.4.8",
"colors": "^1.1.0"
},
"devDependencies": {},
"readmeFilename": "README.md"
Expand Down

0 comments on commit 3612328

Please sign in to comment.