orange-orm 4.5.1-beta.3 → 4.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/README.md +11 -11
  2. package/docs/changelog.md +4 -0
  3. package/package.json +4 -15
  4. package/{dist/index.browser.mjs → src/client/index.mjs} +73 -40
  5. package/src/client/merge.js +9 -0
  6. package/src/{rollup.config.browser.js → client/rollup.config.js} +1 -1
  7. package/src/d1/newTransaction.js +1 -0
  8. package/src/index.js +3 -16
  9. package/src/mssql/newTransaction.js +1 -0
  10. package/src/mssql/pool/newGenericPool.js +2 -9
  11. package/src/mySql/newTransaction.js +1 -0
  12. package/src/mySql/pool/newGenericPool.js +2 -11
  13. package/src/oracle/newTransaction.js +1 -0
  14. package/src/oracle/pool/newGenericPool.js +5 -13
  15. package/src/patchTable.js +4 -1
  16. package/src/pg/newDatabase.js +5 -0
  17. package/src/pg/newTransaction.js +1 -0
  18. package/src/pg/pool/newPgPool.js +3 -15
  19. package/src/sap/newTransaction.js +1 -0
  20. package/src/sqlite/newTransaction.js +1 -0
  21. package/src/{sqlite3 → sqlite}/pool/newGenericPool.js +2 -10
  22. package/src/table/clearCache.js +7 -0
  23. package/src/table/column/binary/newDecode.js +2 -13
  24. package/src/table/column/binary/newEncode.js +6 -16
  25. package/src/table/getSessionCache.js +8 -0
  26. package/src/table/newRowCache.js +4 -4
  27. package/src/table/relation/newManyCache.js +4 -4
  28. package/src/table/resultToRows/newDecodeDbRow.js +1 -1
  29. package/src/table/setSessionCache.js +8 -0
  30. package/src/table/setSessionSingleton.js +1 -1
  31. package/src/tedious/newTransaction.js +1 -0
  32. package/src/tedious/pool/newGenericPool.js +2 -8
  33. package/src/tedious/wrapQuery.js +17 -40
  34. package/dist/index.mjs +0 -20002
  35. package/src/bunPg/newDatabase.js +0 -137
  36. package/src/bunPg/newPool.js +0 -19
  37. package/src/bunPg/pool/end.js +0 -13
  38. package/src/bunPg/pool/newPgPool.js +0 -98
  39. package/src/bunPg/wrapQuery.js +0 -33
  40. package/src/bunSqlite/newPool.js +0 -19
  41. package/src/bunSqlite/newTransaction.js +0 -87
  42. package/src/bunSqlite/pool/newGenericPool.js +0 -55
  43. package/src/bunSqlite/wrapQuery.js +0 -23
  44. package/src/merge-browser.js +0 -9
  45. package/src/merge-server.js +0 -9
  46. package/src/nodeSqlite/decodeBinary.js +0 -9
  47. package/src/nodeSqlite/encodeBinary.js +0 -17
  48. package/src/nodeSqlite/newDatabase.js +0 -116
  49. package/src/nodeSqlite/newPool.js +0 -19
  50. package/src/nodeSqlite/newTransaction.js +0 -87
  51. package/src/nodeSqlite/pool/newGenericPool.js +0 -50
  52. package/src/nodeSqlite/wrapQuery.js +0 -23
  53. package/src/rollup.config.server.js +0 -32
  54. package/src/runtimes.js +0 -24
  55. package/src/sqlite3/deleteFromSql.js +0 -10
  56. package/src/sqlite3/encodeBoolean.js +0 -7
  57. package/src/sqlite3/encodeBuffer.js +0 -7
  58. package/src/sqlite3/insert.js +0 -21
  59. package/src/sqlite3/insertSql.js +0 -67
  60. package/src/sqlite3/lastInsertedSql.js +0 -12
  61. package/src/sqlite3/limitAndOffset.js +0 -18
  62. package/src/sqlite3/newDatabase.js +0 -116
  63. package/src/sqlite3/newTransaction.js +0 -83
  64. package/src/sqlite3/pool/end.js +0 -13
  65. package/src/sqlite3/quote.js +0 -1
  66. package/src/sqlite3/selectForUpdateSql.js +0 -5
  67. /package/src/{bunSqlite → sqlite}/newDatabase.js +0 -0
  68. /package/src/{sqlite3 → sqlite}/newPool.js +0 -0
  69. /package/src/{sqlite3 → sqlite}/wrapQuery.js +0 -0
@@ -1,137 +0,0 @@
1
- let createDomain = require('../createDomain');
2
- let newTransaction = require('../pg/newTransaction');
3
- let _begin = require('../table/begin');
4
- let commit = require('../table/commit');
5
- let rollback = require('../table/rollback');
6
- let newPool = require('./newPool');
7
- let lock = require('../lock');
8
- let executeSchema = require('../pg/schema');
9
- let express = require('../hostExpress');
10
- let hostLocal = require('../hostLocal');
11
- let doQuery = require('../query');
12
- let releaseDbClient = require('../table/releaseDbClient');
13
- let setSessionSingleton = require('../table/setSessionSingleton');
14
-
15
- function newDatabase(connectionString, poolOptions) {
16
- if (!connectionString)
17
- throw new Error('Connection string cannot be empty');
18
- var pool;
19
- if (!poolOptions)
20
- pool = newPool.bind(null, connectionString, poolOptions);
21
- else
22
- pool = newPool(connectionString, poolOptions);
23
-
24
- let c = { poolFactory: pool, hostLocal, express };
25
-
26
- c.transaction = function(options, fn) {
27
- if ((arguments.length === 1) && (typeof options === 'function')) {
28
- fn = options;
29
- options = undefined;
30
- }
31
- let domain = createDomain();
32
-
33
- if (fn)
34
- return domain.run(runInTransaction);
35
- else
36
- return domain.run(run);
37
-
38
- async function runInTransaction() {
39
- let result;
40
- let transaction = newTransaction(domain, pool, options);
41
- await new Promise(transaction)
42
- .then(begin)
43
- .then(negotiateSchema)
44
- .then(() => fn(domain))
45
- .then((res) => result = res)
46
- .then(() => commit(domain))
47
- .then(null, (e) => rollback(domain,e));
48
- return result;
49
- }
50
-
51
- function begin() {
52
- return _begin(domain, options);
53
- }
54
-
55
- function run() {
56
- let p;
57
- let transaction = newTransaction(domain, pool, options);
58
- p = new Promise(transaction);
59
-
60
- return p.then(begin)
61
- .then(negotiateSchema);
62
- }
63
-
64
- function negotiateSchema(previous) {
65
- let schema = options && options.schema;
66
- if (!schema)
67
- return previous;
68
- return executeSchema(domain, schema);
69
- }
70
- };
71
-
72
- c.createTransaction = function(options) {
73
- let domain = createDomain();
74
- let transaction = newTransaction(domain, pool, options);
75
- let p = domain.run(() => new Promise(transaction)
76
- .then(begin).then(negotiateSchema));
77
-
78
- function run(fn) {
79
- return p.then(domain.run.bind(domain, fn));
80
- }
81
-
82
- function begin() {
83
- return _begin(domain, options);
84
- }
85
-
86
- function negotiateSchema(previous) {
87
- let schema = options && options.schema;
88
- if (!schema)
89
- return previous;
90
- return executeSchema(domain,schema);
91
- }
92
-
93
- run.rollback = rollback.bind(null, domain);
94
- run.commit = commit.bind(null, domain);
95
-
96
- return run;
97
- };
98
-
99
- c.query = function(query) {
100
- let domain = createDomain();
101
- let transaction = newTransaction(domain, pool);
102
- let p = domain.run(() => new Promise(transaction)
103
- .then(() => setSessionSingleton(domain, 'changes', []))
104
- .then(() => doQuery(domain, query).then(onResult, onError)));
105
- return p;
106
-
107
- function onResult(result) {
108
- releaseDbClient(domain);
109
- return result;
110
- }
111
-
112
- function onError(e) {
113
- releaseDbClient(domain);
114
- throw e;
115
- }
116
- };
117
-
118
- c.rollback = rollback;
119
- c.commit = commit;
120
- c.lock = lock;
121
- c.schema = executeSchema;
122
-
123
- c.end = function() {
124
- if (poolOptions)
125
- return pool.end();
126
- else
127
- return Promise.resolve();
128
- };
129
-
130
- c.accept = function(caller) {
131
- caller.visitPg();
132
- };
133
-
134
- return c;
135
- }
136
-
137
- module.exports = newDatabase;
@@ -1,19 +0,0 @@
1
- const promisify = require('../promisify');
2
- const pools = require('../pools');
3
- const end = require('./pool/end');
4
- const newPgPool = require('./pool/newPgPool');
5
- const newId = require('../newId');
6
-
7
- function newPool(connectionString, poolOptions) {
8
- let pool = newPgPool(connectionString, poolOptions);
9
- let id = newId();
10
- let boundEnd = end.bind(null, pool, id);
11
- let c = {};
12
-
13
- c.connect = pool.connect;
14
- c.end = promisify(boundEnd);
15
- pools[id] = c;
16
- return c;
17
- }
18
-
19
- module.exports = newPool;
@@ -1,13 +0,0 @@
1
- var pools = require('../../pools');
2
-
3
- function endPool(pgPool, id, done) {
4
- pgPool.drain(onDrained);
5
-
6
- function onDrained() {
7
- pgPool.destroyAllNow();
8
- delete pools[id];
9
- done();
10
- }
11
- }
12
-
13
- module.exports = endPool;
@@ -1,98 +0,0 @@
1
- /* eslint-disable no-prototype-builtins */
2
- //slightly modified code from github.com/brianc/node-postgres
3
- var log = require('../../table/log');
4
-
5
- var defaults = require('../../poolDefaults');
6
- var genericPool = require('../../generic-pool');
7
- var pg;
8
- var parseSearchPathParam = require('../../pg/pool/parseSearchPathParam');
9
-
10
- function newPgPool(connectionString, poolOptions) {
11
- poolOptions = poolOptions || {};
12
-
13
- // @ts-ignore
14
- var pool = genericPool.Pool({
15
- max: poolOptions.size || poolOptions.poolSize || defaults.poolSize,
16
- idleTimeoutMillis: poolOptions.idleTimeout || defaults.poolIdleTimeout,
17
- reapIntervalMillis: poolOptions.reapIntervalMillis || defaults.reapIntervalMillis,
18
- log: poolOptions.log,
19
- create: async function(cb) {
20
- try {
21
- if (!pg) {
22
- const bunImport = await import('bun');
23
- const { sql } = bunImport.default || bunImport;
24
- pg = sql;
25
- }
26
- }
27
- catch(e) {
28
- return cb(e, null);
29
- }
30
- var client = new pg.Client(connectionString);
31
- client.connect(function(err) {
32
- if (err) return cb(err, null);
33
-
34
- //handle connected client background errors by emitting event
35
- //via the pg object and then removing errored client from the pool
36
- client.on('error', function(e) {
37
- pool.emit('error', e, client);
38
-
39
- // If the client is already being destroyed, the error
40
- // occurred during stream ending. Do not attempt to destroy
41
- // the client again.
42
- if (!client._destroying) {
43
- pool.destroy(client);
44
- }
45
- });
46
-
47
- // Remove connection from pool on disconnect
48
- client.on('end', function(_e) {
49
- // Do not enter infinite loop between pool.destroy
50
- // and client 'end' event...
51
- if (!client._destroying) {
52
- pool.destroy(client);
53
- }
54
- });
55
- client.poolCount = 0;
56
- negotiateSearchPath(client, connectionString, (err) => cb(err, client));
57
-
58
- });
59
- },
60
- destroy: function(client) {
61
- client._destroying = true;
62
- client.poolCount = undefined;
63
- client.end();
64
- }
65
- });
66
- //monkey-patch with connect method
67
- pool.connect = function(cb) {
68
- pool.acquire(function(err, client) {
69
- if (err) return cb(err, null, function() {
70
- /*NOOP*/
71
- });
72
- client.poolCount++;
73
- cb(null, client, function(err) {
74
- if (err) {
75
- pool.destroy(client);
76
- } else {
77
- pool.release(client);
78
- }
79
- });
80
- });
81
- };
82
- return pool;
83
- }
84
-
85
- function negotiateSearchPath(client, connectionString, cb) {
86
- const searchPath = parseSearchPathParam(connectionString);
87
- if (searchPath) {
88
- const sql = `set search_path to ${searchPath}`;
89
- log.emitQuery({sql, parameters: []});
90
- return client.query(sql, cb);
91
- }
92
- else
93
- cb();
94
-
95
-
96
- }
97
-
98
- module.exports = newPgPool;
@@ -1,33 +0,0 @@
1
- var log = require('../table/log');
2
- var replaceParamChar = require('../pg/replaceParamChar');
3
-
4
- function wrapQuery(connection) {
5
- var runOriginalQuery = connection.query;
6
- return runQuery;
7
-
8
- function runQuery(query, onCompleted) {
9
- var params = query.parameters;
10
- var sql = replaceParamChar(query, params);
11
- query = {
12
- text: sql,
13
- values: params,
14
- types: query.types
15
- };
16
- log.emitQuery({sql, parameters: params});
17
-
18
- runOriginalQuery.call(connection, query, onInnerCompleted);
19
-
20
- function onInnerCompleted(err, result) {
21
- if (err)
22
- onCompleted(err);
23
- else {
24
- if (Array.isArray(result))
25
- result = result[result.length-1];
26
- onCompleted(null, result.rows);
27
- }
28
- }
29
- }
30
-
31
- }
32
-
33
- module.exports = wrapQuery;
@@ -1,19 +0,0 @@
1
- const promisify = require('../promisify');
2
- const pools = require('../pools');
3
- const end = require('../sqlite/pool/end');
4
- const newGenericPool = require('./pool/newGenericPool');
5
- const newId = require('../newId');
6
-
7
- function newPool(connectionString, poolOptions) {
8
- let pool = newGenericPool(connectionString, poolOptions);
9
- let id = newId();
10
- let boundEnd = end.bind(null, pool, id);
11
- let c = {};
12
-
13
- c.connect = pool.connect;
14
- c.end = promisify(boundEnd);
15
- pools[id] = c;
16
- return c;
17
- }
18
-
19
- module.exports = newPool;
@@ -1,87 +0,0 @@
1
- const wrapQuery = require('./wrapQuery');
2
- const encodeBoolean = require('../sqlite/encodeBoolean');
3
- const encodeBinary = require('../nodeSqlite/encodeBinary');
4
- const decodeBinary = require('../nodeSqlite/decodeBinary');
5
- const deleteFromSql = require('../sqlite/deleteFromSql');
6
- const selectForUpdateSql = require('../sqlite/selectForUpdateSql');
7
- const lastInsertedSql = require('../sqlite/lastInsertedSql');
8
- const limitAndOffset = require('../sqlite/limitAndOffset');
9
- const insertSql = require('../sqlite/insertSql');
10
- const insert = require('../sqlite/insert');
11
- const quote = require('../sqlite/quote');
12
-
13
- function newResolveTransaction(domain, pool, { readonly = false } = {}) {
14
- var rdb = {poolFactory: pool};
15
- if (!pool.connect) {
16
- pool = pool();
17
- rdb.pool = pool;
18
- }
19
- rdb.engine = 'sqlite';
20
- rdb.encodeBoolean = encodeBoolean;
21
- rdb.encodeBinary = encodeBinary;
22
- rdb.decodeBinary = decodeBinary;
23
- rdb.decodeJSON = decodeJSON;
24
- rdb.encodeJSON = JSON.stringify;
25
- rdb.deleteFromSql = deleteFromSql;
26
- rdb.selectForUpdateSql = selectForUpdateSql;
27
- rdb.lastInsertedSql = lastInsertedSql;
28
- rdb.insertSql = insertSql;
29
- rdb.insert = insert;
30
- rdb.lastInsertedIsSeparate = true;
31
- rdb.multipleStatements = false;
32
- rdb.limitAndOffset = limitAndOffset;
33
- rdb.accept = function(caller) {
34
- caller.visitSqlite();
35
- };
36
- rdb.aggregateCount = 0;
37
- rdb.quote = quote;
38
-
39
- if (readonly) {
40
- rdb.dbClient = {
41
- executeQuery: function(query, callback) {
42
- pool.connect((err, client, done) => {
43
- if (err) {
44
- return callback(err);
45
- }
46
- try {
47
- wrapQuery(client)(query, (err, res) => {
48
- done();
49
- callback(err, res);
50
- });
51
- } catch (e) {
52
- done();
53
- callback(e);
54
- }
55
- });
56
- }
57
- };
58
- domain.rdb = rdb;
59
- return (onSuccess) => onSuccess();
60
- }
61
-
62
- return function(onSuccess, onError) {
63
- pool.connect(onConnected);
64
-
65
- function onConnected(err, client, done) {
66
- try {
67
- if (err) {
68
- onError(err);
69
- return;
70
- }
71
- client.executeQuery = wrapQuery(client);
72
- rdb.dbClient = client;
73
- rdb.dbClientDone = done;
74
- domain.rdb = rdb;
75
- onSuccess();
76
- } catch (e) {
77
- onError(e);
78
- }
79
- }
80
- };
81
- }
82
-
83
- function decodeJSON(value) {
84
- return JSON.parse(value);
85
- }
86
-
87
- module.exports = newResolveTransaction;
@@ -1,55 +0,0 @@
1
- /* eslint-disable no-prototype-builtins */
2
- var defaults = require('../../poolDefaults');
3
-
4
- var genericPool = require('../../generic-pool');
5
- var Database;
6
-
7
- function newGenericPool(connectionString, poolOptions) {
8
- poolOptions = poolOptions || {};
9
- var pool = genericPool.Pool({
10
- max: poolOptions.size || poolOptions.poolSize || defaults.poolSize,
11
- idleTimeoutMillis: poolOptions.idleTimeout || defaults.poolIdleTimeout,
12
- reapIntervalMillis: poolOptions.reapIntervalMillis || defaults.reapIntervalMillis,
13
- log: poolOptions.log || defaults.poolLog,
14
- create: async function(cb) {
15
- try {
16
- try {
17
- if (!Database)
18
- ({ Database } = await import('bun:Database'));
19
- }
20
- catch (err) {
21
- return cb(err, null);
22
- }
23
-
24
- var client = new Database(connectionString);
25
- client.poolCount = 0;
26
- cb(null, client);
27
- }
28
- catch(err) {
29
- return cb(err, null);
30
- }
31
- },
32
-
33
- destroy: function(client) {
34
- client.poolCount = undefined;
35
- client.close();
36
- }
37
- });
38
- //monkey-patch with connect method
39
- pool.connect = function(cb) {
40
- pool.acquire(function(err, client) {
41
- if(err) return cb(err, null, function() {/*NOOP*/});
42
- client.poolCount++;
43
- cb(null, client, function(err) {
44
- if(err) {
45
- pool.destroy(client);
46
- } else {
47
- pool.release(client);
48
- }
49
- });
50
- });
51
- };
52
- return pool;
53
- }
54
-
55
- module.exports = newGenericPool;
@@ -1,23 +0,0 @@
1
- var log = require('../table/log');
2
-
3
- function wrapQuery(connection) {
4
- return runQuery;
5
-
6
- function runQuery(query, onCompleted) {
7
- try {
8
- var params = query.parameters;
9
- var sql = query.sql();
10
- log.emitQuery({ sql, parameters: params });
11
-
12
- var statement = connection.query(sql);
13
- const rows = statement.all.apply(statement, params);
14
- onCompleted(null, rows);
15
- }
16
- catch (e) {
17
- onCompleted(e);
18
- }
19
- }
20
-
21
- }
22
-
23
- module.exports = wrapQuery;
@@ -1,9 +0,0 @@
1
- const fs = require('fs').promises;
2
-
3
- async function merge() {
4
- let data1 = await fs.readFile('./src/client/self.js', 'utf8');
5
- let data2 = await fs.readFile('./dist/index.browser.mjs', 'utf8');
6
- await fs.writeFile('./dist/index.browser.mjs', data1 + data2);
7
- }
8
-
9
- merge();
@@ -1,9 +0,0 @@
1
- const fs = require('fs').promises;
2
-
3
- async function merge() {
4
- let data1 = await fs.readFile('./src/client/self.js', 'utf8');
5
- let data2 = await fs.readFile('./dist/index.mjs', 'utf8');
6
- await fs.writeFile('./dist/index.mjs', data1 + data2);
7
- }
8
-
9
- merge();
@@ -1,9 +0,0 @@
1
- function decodeBinary(u8Arr) {
2
- let binaryString = '';
3
- for (let i = 0; i < u8Arr.length; i++) {
4
- binaryString += String.fromCharCode(u8Arr[i]);
5
- }
6
- return btoa(binaryString);
7
- }
8
-
9
- module.exports = decodeBinary;
@@ -1,17 +0,0 @@
1
- function encodeBinary(base64) {
2
- // Decode base64 to a binary string
3
- const binaryString = atob(base64);
4
-
5
- // Create a new Uint8Array with the same length as the binary string
6
- const len = binaryString.length;
7
- const bytes = new Uint8Array(len);
8
-
9
- // Populate the Uint8Array with numeric character codes
10
- for (let i = 0; i < len; i++) {
11
- bytes[i] = binaryString.charCodeAt(i);
12
- }
13
-
14
- return bytes;
15
- }
16
-
17
- module.exports = encodeBinary;
@@ -1,116 +0,0 @@
1
- let createDomain = require('../createDomain');
2
- let newTransaction = require('./newTransaction');
3
- let _begin = require('../table/begin');
4
- let commit = require('../table/commit');
5
- let rollback = require('../table/rollback');
6
- let newPool = require('./newPool');
7
- let express = require('../hostExpress');
8
- let hostLocal = require('../hostLocal');
9
- let doQuery = require('../query');
10
- let releaseDbClient = require('../table/releaseDbClient');
11
- let setSessionSingleton = require('../table/setSessionSingleton');
12
-
13
- function newDatabase(connectionString, poolOptions) {
14
- if (!connectionString)
15
- throw new Error('Connection string cannot be empty');
16
- var pool;
17
- if (!poolOptions)
18
- pool = newPool.bind(null,connectionString, poolOptions);
19
- else
20
- pool = newPool(connectionString, poolOptions);
21
-
22
- let c = {poolFactory: pool, hostLocal, express};
23
-
24
- c.transaction = function(options, fn) {
25
- if ((arguments.length === 1) && (typeof options === 'function')) {
26
- fn = options;
27
- options = undefined;
28
- }
29
- let domain = createDomain();
30
-
31
- if (fn)
32
- return domain.run(runInTransaction);
33
- else
34
- return domain.run(run);
35
-
36
- function begin() {
37
- return _begin(domain, options);
38
- }
39
-
40
- async function runInTransaction() {
41
- let result;
42
- let transaction = newTransaction(domain, pool, options);
43
- await new Promise(transaction)
44
- .then(begin)
45
- .then(() => fn(domain))
46
- .then((res) => result = res)
47
- .then(() => commit(domain))
48
- .then(null, (e) => rollback(domain, e));
49
- return result;
50
- }
51
-
52
- function run() {
53
- let p;
54
- let transaction = newTransaction(domain, pool, options);
55
- p = new Promise(transaction);
56
-
57
- return p.then(begin);
58
- }
59
-
60
- };
61
-
62
- c.createTransaction = function(options) {
63
- let domain = createDomain();
64
- let transaction = newTransaction(domain, pool);
65
- let p = domain.run(() => new Promise(transaction).then(begin));
66
-
67
- function run(fn) {
68
- return p.then(() => fn(domain));
69
- }
70
- run.rollback = rollback.bind(null, domain);
71
- run.commit = commit.bind(null, domain);
72
- return run;
73
-
74
- function begin() {
75
- return _begin(domain, options);
76
- }
77
- };
78
-
79
- c.query = function(query) {
80
- let domain = createDomain();
81
- let transaction = newTransaction(domain, pool);
82
- let p = domain.run(() => new Promise(transaction)
83
- .then(() => setSessionSingleton(domain, 'changes', []))
84
- .then(() => doQuery(domain, query).then(onResult, onError)));
85
- return p;
86
-
87
- function onResult(result) {
88
- releaseDbClient(domain);
89
- return result;
90
- }
91
-
92
- function onError(e) {
93
- releaseDbClient(domain);
94
- throw e;
95
- }
96
- };
97
-
98
-
99
- c.rollback = rollback;
100
- c.commit = commit;
101
-
102
- c.end = function() {
103
- if (poolOptions)
104
- return pool.end();
105
- else
106
- return Promise.resolve();
107
- };
108
-
109
- c.accept = function(caller) {
110
- caller.visitSqlite();
111
- };
112
-
113
- return c;
114
- }
115
-
116
- module.exports = newDatabase;
@@ -1,19 +0,0 @@
1
- const promisify = require('../promisify');
2
- const pools = require('../pools');
3
- const end = require('../sqlite/pool/end');
4
- const newGenericPool = require('./pool/newGenericPool');
5
- const newId = require('../newId');
6
-
7
- function newPool(connectionString, poolOptions) {
8
- let pool = newGenericPool(connectionString, poolOptions);
9
- let id = newId();
10
- let boundEnd = end.bind(null, pool, id);
11
- let c = {};
12
-
13
- c.connect = pool.connect;
14
- c.end = promisify(boundEnd);
15
- pools[id] = c;
16
- return c;
17
- }
18
-
19
- module.exports = newPool;