Skip to content

Commit 37afa42

Browse files
authored
fix: should export conn property (ali-sdk#101)
1 parent 907a89b commit 37afa42

File tree

3 files changed

+35
-20
lines changed

3 files changed

+35
-20
lines changed

.github/workflows/release.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
7+
workflow_dispatch: {}
8+
9+
jobs:
10+
release:
11+
name: Node.js
12+
uses: artusjs/github-actions/.github/workflows/node-release.yml@v1
13+
secrets:
14+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
15+
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
16+
with:
17+
checkTest: false

lib/connection.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,40 @@ const Operator = require('./operator');
44
const kWrapToRDS = Symbol('kWrapToRDS');
55

66
class RDSConnection extends Operator {
7-
#conn;
87
constructor(conn) {
98
super();
10-
this.#conn = conn;
11-
if (!this.#conn[kWrapToRDS]) {
9+
this.conn = conn;
10+
if (!this.conn[kWrapToRDS]) {
1211
[
1312
'query',
1413
'beginTransaction',
1514
'commit',
1615
'rollback',
1716
].forEach(key => {
18-
this.#conn[key] = promisify(this.#conn[key]);
17+
this.conn[key] = promisify(this.conn[key]);
1918
});
20-
this.#conn[kWrapToRDS] = true;
19+
this.conn[kWrapToRDS] = true;
2120
}
2221
}
2322

2423
release() {
25-
return this.#conn.release();
24+
return this.conn.release();
2625
}
2726

2827
async _query(sql) {
29-
return await this.#conn.query(sql);
28+
return await this.conn.query(sql);
3029
}
3130

3231
async beginTransaction() {
33-
return await this.#conn.beginTransaction();
32+
return await this.conn.beginTransaction();
3433
}
3534

3635
async commit() {
37-
return await this.#conn.commit();
36+
return await this.conn.commit();
3837
}
3938

4039
async rollback() {
41-
return await this.#conn.rollback();
40+
return await this.conn.rollback();
4241
}
4342
}
4443

lib/transaction.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
11
const Operator = require('./operator');
22

33
class RDSTransaction extends Operator {
4-
#conn;
54
isCommit = false;
65
isRollback = false;
76
constructor(conn) {
87
super();
9-
this.#conn = conn;
8+
this.conn = conn;
109
}
1110

1211
async commit() {
1312
this.#check();
1413
try {
15-
return await this.#conn.commit();
14+
return await this.conn.commit();
1615
} finally {
1716
this.isCommit = true;
18-
this.#conn.release();
19-
this.#conn = null;
17+
this.conn.release();
18+
this.conn = null;
2019
}
2120
}
2221

2322
async rollback() {
2423
this.#check();
2524
try {
26-
return await this.#conn.rollback();
25+
return await this.conn.rollback();
2726
} finally {
2827
this.isRollback = true;
29-
this.#conn.release();
30-
this.#conn = null;
28+
this.conn.release();
29+
this.conn = null;
3130
}
3231
}
3332

3433
async _query(sql) {
3534
this.#check();
36-
return await this.#conn._query(sql);
35+
return await this.conn._query(sql);
3736
}
3837

3938
#check() {
40-
if (!this.#conn) {
39+
if (!this.conn) {
4140
throw new Error('transaction was commit or rollback');
4241
}
4342
}

0 commit comments

Comments
 (0)