-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoc-promise.js
87 lines (55 loc) · 1.26 KB
/
poc-promise.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//libraries
var Q = require('q'),
fs = require('fs'),
log4js = require('log4js'),
_ = require('underscore');
//settings
var startTimer;
var dbConn = {
host : 'localhost',
user : 'root',
password : 'root',
// debug : true,
database : 'aa',
connectionLimit: 10
};
mvDb = require('./dbsrc').dbSrc(dbConn);
//init
log4js.configure({
appenders: [ { type: "console" }],
replaceConsole: true
});
var logger = log4js.getLogger();
// connection.on('error', function() {}); //common error event
//app
//error handling
var pErr = function(err){
console.error('err', err);
};
var aa = new dbSrc(dbConn);
startTimer = new Date();
// console.log('q1', new Date() - startTimer);
// _.each(_.range(1,21), function(i){
// MySqlDemo.prototype.queryDb('select sleep('+1+')')
// .then(
// function(rows){
// console.log('done q'+i, new Date() - startTimer);
// // console.log(rows);
// }, pErr
// );
// })
var a = function(){
console.log('aa');
_.each(_.range(1,21), function(i){
// aa.queryDb('select sleep('+0.01+')')
aa.queryDb('SELECT lid from locales_source')
.then(
function(rows, fields){
console.log('done q'+i, new Date() - startTimer);
// console.log(rows);
}, pErr
);
})
}
//start
// a()