Skip to content

Commit 1845a98

Browse files
author
Lars-Erik Roald
committed
removed unused
1 parent 0d18fb6 commit 1845a98

File tree

12 files changed

+38
-140
lines changed

12 files changed

+38
-140
lines changed

src/bunPg/newDatabase.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ function newDatabase(connectionString, poolOptions) {
2626
}
2727
let domain = createDomain();
2828

29-
if (fn)
30-
return domain.run(runInTransaction);
31-
else
32-
return domain.run(run);
29+
if (!fn)
30+
throw new Error('transaction requires a function');
31+
return domain.run(runInTransaction);
3332

3433
async function runInTransaction() {
3534
let result;
@@ -48,14 +47,6 @@ function newDatabase(connectionString, poolOptions) {
4847
return _begin(domain, options);
4948
}
5049

51-
function run() {
52-
let p;
53-
let transaction = newTransaction(domain, pool, options);
54-
p = new Promise(transaction);
55-
56-
return p.then(begin)
57-
.then(negotiateSchema);
58-
}
5950

6051
function negotiateSchema(previous) {
6152
let schema = options && options.schema;

src/bunSqlite/newDatabase.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ function newDatabase(connectionString, poolOptions) {
2525
}
2626
let domain = createDomain();
2727

28-
if (fn)
29-
return domain.run(runInTransaction);
30-
else
31-
return domain.run(run);
28+
if (!fn)
29+
throw new Error('transaction requires a function');
30+
return domain.run(runInTransaction);
3231

3332
function begin() {
3433
return _begin(domain, options);
@@ -46,13 +45,6 @@ function newDatabase(connectionString, poolOptions) {
4645
return result;
4746
}
4847

49-
function run() {
50-
let p;
51-
let transaction = newTransaction(domain, pool, options);
52-
p = new Promise(transaction);
53-
54-
return p.then(begin);
55-
}
5648

5749
};
5850

src/d1/newDatabase.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ function newDatabase(d1Database, poolOptions) {
2424
}
2525
let domain = createDomain();
2626

27-
if (fn)
28-
return domain.run(runInTransaction);
29-
else
30-
return domain.run(run);
27+
if (!fn)
28+
throw new Error('transaction requires a function');
29+
return domain.run(runInTransaction);
3130

3231
async function runInTransaction() {
3332
let result;
@@ -46,13 +45,6 @@ function newDatabase(d1Database, poolOptions) {
4645
return _begin(domain, transactionLess);
4746
}
4847

49-
function run() {
50-
let p;
51-
let transaction = newTransaction(domain, pool, options);
52-
p = new Promise(transaction);
53-
54-
return p.then(begin);
55-
}
5648

5749
};
5850

src/mssql/newDatabase.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ function newDatabase(connectionString, poolOptions) {
2424
}
2525
let domain = createDomain();
2626

27-
if (fn)
28-
return domain.run(runInTransaction);
29-
else
30-
return domain.run(run);
27+
if (!fn)
28+
throw new Error('transaction requires a function');
29+
return domain.run(runInTransaction);
3130

3231
async function runInTransaction() {
3332
let result;
@@ -45,13 +44,6 @@ function newDatabase(connectionString, poolOptions) {
4544
return _begin(domain, options);
4645
}
4746

48-
function run() {
49-
let p;
50-
let transaction = newTransaction(domain, pool, options);
51-
p = new Promise(transaction);
52-
53-
return p.then(begin);
54-
}
5547

5648
};
5749

src/mySql/newDatabase.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ function newDatabase(connectionString, poolOptions) {
2424
}
2525
let domain = createDomain();
2626

27-
if (fn)
28-
return domain.run(runInTransaction);
29-
else
30-
return domain.run(run);
27+
if (!fn)
28+
throw new Error('transaction requires a function');
29+
return domain.run(runInTransaction);
3130

3231
async function runInTransaction() {
3332
let result;
@@ -45,13 +44,6 @@ function newDatabase(connectionString, poolOptions) {
4544
return _begin(domain, options);
4645
}
4746

48-
function run() {
49-
let p;
50-
let transaction = newTransaction(domain, pool, options);
51-
p = new Promise(transaction);
52-
53-
return p.then(begin);
54-
}
5547

5648
};
5749

src/nodeSqlite/newDatabase.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@ function newDatabase(connectionString, poolOptions, hooks) {
4242
let domain = createDomain();
4343
const req = domain && domain.req;
4444

45-
if (fn) {
46-
console.dir('run fn in trans........');
47-
return domain.run(runInTransaction);
48-
}
49-
else
50-
return domain.run(run);
45+
if (!fn)
46+
throw new Error('transaction requires a function');
47+
console.dir('run fn in trans........');
48+
return domain.run(runInTransaction);
5149

5250
function begin() {
5351
return Promise.resolve()
@@ -72,14 +70,6 @@ function newDatabase(connectionString, poolOptions, hooks) {
7270
return result;
7371
}
7472

75-
function run() {
76-
//todo delete ?
77-
let p;
78-
let transaction = newTransaction(domain, pool, options);
79-
p = new Promise(transaction);
80-
81-
return p.then(begin);
82-
}
8373

8474
};
8575

src/oracle/newDatabase.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ function newDatabase(connectionString, poolOptions) {
2424
}
2525
let domain = createDomain();
2626

27-
if (fn)
28-
return domain.run(runInTransaction);
29-
else
30-
return domain.run(run);
27+
if (!fn)
28+
throw new Error('transaction requires a function');
29+
return domain.run(runInTransaction);
3130

3231

3332
function begin() {
@@ -47,13 +46,6 @@ function newDatabase(connectionString, poolOptions) {
4746

4847
}
4948

50-
function run() {
51-
let p;
52-
let transaction = newTransaction(domain, pool, options);
53-
p = new Promise(transaction);
54-
55-
return p.then(begin);
56-
}
5749

5850
};
5951

src/pg/newDatabase.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ function newDatabase(connectionString, poolOptions) {
2626
}
2727
let domain = createDomain();
2828

29-
if (fn)
30-
return domain.run(runInTransaction);
31-
else
32-
return domain.run(run);
29+
if (!fn)
30+
throw new Error('transaction requires a function');
31+
return domain.run(runInTransaction);
3332

3433
async function runInTransaction() {
3534
let result;
@@ -48,15 +47,6 @@ function newDatabase(connectionString, poolOptions) {
4847
return _begin(domain, options);
4948
}
5049

51-
function run() {
52-
let p;
53-
let transaction = newTransaction(domain, pool, options);
54-
p = new Promise(transaction);
55-
56-
return p.then(begin)
57-
.then(negotiateSchema);
58-
}
59-
6050
function negotiateSchema(previous) {
6151
let schema = options && options.schema;
6252
if (!schema)
@@ -129,4 +119,4 @@ function newDatabase(connectionString, poolOptions) {
129119
return c;
130120
}
131121

132-
module.exports = newDatabase;
122+
module.exports = newDatabase;

src/pglite/newDatabase.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ function newDatabase(connectionString, poolOptions) {
2424
}
2525
let domain = createDomain();
2626

27-
if (fn)
28-
return domain.run(runInTransaction);
29-
else
30-
return domain.run(run);
27+
if (!fn)
28+
throw new Error('transaction requires a function');
29+
return domain.run(runInTransaction);
3130

3231
async function runInTransaction() {
3332
let result;
@@ -46,14 +45,6 @@ function newDatabase(connectionString, poolOptions) {
4645
return _begin(domain, options);
4746
}
4847

49-
function run() {
50-
let p;
51-
let transaction = newTransaction(domain, pool, options);
52-
p = new Promise(transaction);
53-
54-
return p.then(begin)
55-
.then(negotiateSchema);
56-
}
5748

5849
function negotiateSchema(previous) {
5950
let schema = options && options.schema;

src/sap/newDatabase.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ function newDatabase(connectionString, poolOptions) {
2424
}
2525
let domain = createDomain();
2626

27-
if (fn)
28-
return domain.run(runInTransaction);
29-
else
30-
return domain.run(run);
27+
if (!fn)
28+
throw new Error('transaction requires a function');
29+
return domain.run(runInTransaction);
3130

3231

3332
function begin() {
@@ -47,13 +46,6 @@ function newDatabase(connectionString, poolOptions) {
4746

4847
}
4948

50-
function run() {
51-
let p;
52-
let transaction = newTransaction(domain, pool, options);
53-
p = new Promise(transaction);
54-
55-
return p.then(begin);
56-
}
5749

5850
};
5951

0 commit comments

Comments
 (0)