@e-mc/db 0.0.2 → 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 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 /* TRANSACTION_DB.TERMINATE */);
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 /* TRANSACTION_DB.ABORT */);
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 /* TRANSACTION_DB.FAIL */);
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 /* TRANSACTION_DB.ABORT */);
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, sep = path.sep;
228
- if (source[0] === '@') {
229
- if ((result = source).indexOf('/') === -1) {
230
- folder || (folder = 'client');
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 (!Db.isDir(result = path.join(__dirname, source))) {
235
- result = source;
236
- sep = '/';
243
+ else if ((result = source).indexOf('/') === -1) {
244
+ folder || (folder = 'client');
237
245
  }
238
- return result + (folder ? sep + 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,7 +1,7 @@
1
1
  {
2
2
  "name": "@e-mc/db",
3
- "version": "0.0.2",
4
- "description": "DB modules for e-mc.",
3
+ "version": "0.0.4",
4
+ "description": "DB modules for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "publishConfig": {
@@ -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.2",
24
- "@e-mc/request": "0.0.2"
23
+ "@e-mc/core": "0.0.4",
24
+ "@e-mc/request": "0.0.4"
25
25
  }
26
26
  }
@@ -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;