-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patht.js
43 lines (36 loc) · 841 Bytes
/
t.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
require( "sleepless" );
sleepless.globalize();
inspect = function( o, d ) { return require( "util" ).inspect( o, d ) }
dump = function( o, d ) { log( inspect( o, d ) ); }
function okay( a ) {
log( "OKAY: " + inspect(a) );
}
function fail( a ) {
console.warn( "FAIL: " + inspect(a) );
}
require("./").mysql.connect({
host:"db.sleepless.com",
user:"socrabot",
password:"NqCQf7xtMm8v7SKd",
database:"socrabot"
}, db => {
log("connected");
db.start( (x) => {
log(x);
log('started');
db.update( "update audit_log set msg='foo' where id=4362 limit 1", [], n => {
log(n);
if( toInt(Math.random() * 2) % 2 == 0 ) {
db.commit( () => {
log('committed');
db.end();
}, fail );
} else {
db.rollback( () => {
log('rolled back');
db.end();
}, fail );
}
}, fail );
}, fail);
}, fail);