mysql-dao
v0.0.3
Published
this is a useful abstraction for mysql
Downloads
7
Readme
<pre>
var mysql = require('mysql');
var datasource = mysql.createPool({
host : 'localhost',
user : 'test',
database:'test'
});
var MysqlDao = require('./dao.js');
var dao = MysqlDao({datasource:datasource});
dao.doIntransaction(function(callback){
dao.currentConnection.query('insert into tbl_test set ?',{name:'tarsen',age:10},callback);
},function(err,result){
console.log(err);
console.log(result);
});
dao.insert('tbl_test',{name:'tarsen',age:10},function(err,result){
console.log(err);
console.log(result);
});
dao.update('tbl_test',1,{name:'tarsean_new'},function(err,result){
console.log(err);
console.log(result);
});
dao.delete('tbl_test',8,function(err,result){
console.log(err);
console.log(result);
});
</pre>
</p>
<p>
advanced usage:
if the tasks must executed in order,you set the options.execute
<pre>
var MysqlDao = require('./dao.js');
var dao = MysqlDao({datasource:datasource,execute:'waterfall'});
the value of execute can be : parallel(default),series,waterfall
when use waterfall,the previous result will be passed to the next one
</pre>
</p>