@e-mc/db 0.0.3 → 0.0.4
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.
- package/index.js +21 -13
- package/package.json +3 -3
- package/mongodb/index.d.ts +0 -12
- package/mongodb/index.js +0 -679
- package/mssql/index.d.ts +0 -7
- package/mssql/index.js +0 -505
- package/mysql/index.d.ts +0 -10
- package/mysql/index.js +0 -332
- package/oracle/index.d.ts +0 -7
- package/oracle/index.js +0 -358
- package/postgres/index.d.ts +0 -7
- package/postgres/index.js +0 -272
- package/redis/index.d.ts +0 -7
- package/redis/index.js +0 -550
package/index.js
CHANGED
|
@@ -120,7 +120,7 @@ class Db extends core_1.ClientDb {
|
|
|
120
120
|
({ disconnect, parallel } = parallel);
|
|
121
121
|
}
|
|
122
122
|
const terminate = () => {
|
|
123
|
-
this.applyState(batch, 8 /*
|
|
123
|
+
this.applyState(batch, 8 /* DB_TRANSACTION.TERMINATE */);
|
|
124
124
|
if (typeof disconnect === 'function') {
|
|
125
125
|
try {
|
|
126
126
|
disconnect();
|
|
@@ -130,7 +130,7 @@ class Db extends core_1.ClientDb {
|
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
132
|
const cleanup = () => {
|
|
133
|
-
this.applyState(batch, 16 /*
|
|
133
|
+
this.applyState(batch, 16 /* DB_TRANSACTION.ABORT */);
|
|
134
134
|
terminate();
|
|
135
135
|
if (outResult) {
|
|
136
136
|
for (let i = 0, length = outResult.length; i < length; ++i) {
|
|
@@ -161,7 +161,7 @@ class Db extends core_1.ClientDb {
|
|
|
161
161
|
.catch(() => cleanup());
|
|
162
162
|
}
|
|
163
163
|
handleFail(err, item, options) {
|
|
164
|
-
this.add(item, 32 /*
|
|
164
|
+
this.add(item, 32 /* DB_TRANSACTION.FAIL */);
|
|
165
165
|
item.transactionFail = true;
|
|
166
166
|
if (options && typeof options.errorQuery === 'function') {
|
|
167
167
|
if (options.errorQuery(err, item, options.commandType)) {
|
|
@@ -186,7 +186,7 @@ class Db extends core_1.ClientDb {
|
|
|
186
186
|
const tasks = (items || this.pending).map(data => {
|
|
187
187
|
data.ignoreCache ?? (data.ignoreCache = true);
|
|
188
188
|
return this.executeQuery(data).catch(() => {
|
|
189
|
-
this.applyState([data], 16 /*
|
|
189
|
+
this.applyState([data], 16 /* DB_TRANSACTION.ABORT */);
|
|
190
190
|
return [];
|
|
191
191
|
});
|
|
192
192
|
});
|
|
@@ -224,18 +224,26 @@ class Db extends core_1.ClientDb {
|
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
resolveSource(source, folder) {
|
|
227
|
-
let result
|
|
228
|
-
if (source[0]
|
|
229
|
-
|
|
230
|
-
|
|
227
|
+
let result;
|
|
228
|
+
if (source[0] !== '@') {
|
|
229
|
+
switch (source) {
|
|
230
|
+
case 'mongodb':
|
|
231
|
+
case 'mssql':
|
|
232
|
+
case 'mysql':
|
|
233
|
+
case 'oracle':
|
|
234
|
+
case 'postgres':
|
|
235
|
+
case 'redis':
|
|
236
|
+
result = '@e-mc2/' + source;
|
|
237
|
+
break;
|
|
238
|
+
default:
|
|
239
|
+
result = source;
|
|
240
|
+
break;
|
|
231
241
|
}
|
|
232
|
-
sep = '/';
|
|
233
242
|
}
|
|
234
|
-
else if (
|
|
235
|
-
|
|
236
|
-
sep = '/';
|
|
243
|
+
else if ((result = source).indexOf('/') === -1) {
|
|
244
|
+
folder || (folder = 'client');
|
|
237
245
|
}
|
|
238
|
-
return result + (folder ?
|
|
246
|
+
return result + (folder ? '/' + folder : '');
|
|
239
247
|
}
|
|
240
248
|
getPoolConfig(source, uuidKey) {
|
|
241
249
|
const config = Db.getPoolConfig(source);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/db",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "DB modules for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"license": "BSD 3-Clause",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/core": "0.0.
|
|
24
|
-
"@e-mc/request": "0.0.
|
|
23
|
+
"@e-mc/core": "0.0.4",
|
|
24
|
+
"@e-mc/request": "0.0.4"
|
|
25
25
|
}
|
|
26
26
|
}
|
package/mongodb/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { MongoDBDataSource, MongoDBFilterValue, MongoDBSortValue } from '../../types/lib/db';
|
|
2
|
-
|
|
3
|
-
import type { IDbSourceClient } from '../types';
|
|
4
|
-
|
|
5
|
-
import type { CommandOperationOptions, Document, Filter, Sort, SortDirection } from 'mongodb';
|
|
6
|
-
|
|
7
|
-
declare const MongoDB: IDbSourceClient<MongoDBDataSource> & {
|
|
8
|
-
getFilterValue: (query: Filter<Document> | MongoDBFilterValue, coerce?: boolean) => [Filter<Document>, CommandOperationOptions?];
|
|
9
|
-
getSortValue: (sort: Sort | string | MongoDBSortValue, coerce?: boolean) => [Sort | string, SortDirection?];
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export = MongoDB;
|