@e-mc/db 0.11.17 → 0.11.19
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/README.md +7 -7
- package/index.js +54 -25
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## Interface
|
|
11
11
|
|
|
12
|
-
* [View Source](https://www.unpkg.com/@e-mc/types@0.11.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.11.19/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { DbDataSource } from "./squared";
|
|
@@ -204,14 +204,14 @@ const [rows1, rows2] = await instance.executeBatchQuery([
|
|
|
204
204
|
|
|
205
205
|
## References
|
|
206
206
|
|
|
207
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
208
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
209
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
210
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
211
|
-
- https://www.unpkg.com/@e-mc/types@0.11.
|
|
207
|
+
- https://www.unpkg.com/@e-mc/types@0.11.19/lib/squared.d.ts
|
|
208
|
+
- https://www.unpkg.com/@e-mc/types@0.11.19/lib/core.d.ts
|
|
209
|
+
- https://www.unpkg.com/@e-mc/types@0.11.19/lib/db.d.ts
|
|
210
|
+
- https://www.unpkg.com/@e-mc/types@0.11.19/lib/http.d.ts
|
|
211
|
+
- https://www.unpkg.com/@e-mc/types@0.11.19/lib/settings.d.ts
|
|
212
212
|
|
|
213
213
|
* https://www.npmjs.com/package/@types/node
|
|
214
214
|
|
|
215
215
|
## LICENSE
|
|
216
216
|
|
|
217
|
-
|
|
217
|
+
MIT
|
package/index.js
CHANGED
|
@@ -93,32 +93,56 @@ class Db extends core_1.ClientDb {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
applyCommand(...items) {
|
|
96
|
-
|
|
96
|
+
const sourceMap = {};
|
|
97
97
|
for (let i = 0, length = items.length; i < length; ++i) {
|
|
98
98
|
const item = items[i];
|
|
99
99
|
const command = item.withCommand;
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if ('credential' in data) {
|
|
116
|
-
delete data.credential;
|
|
100
|
+
if (command) {
|
|
101
|
+
const source = item.source;
|
|
102
|
+
const data = sourceMap[source];
|
|
103
|
+
if (!data) {
|
|
104
|
+
const settings = this.getUserSettings()?.[source]?.commands;
|
|
105
|
+
if (settings) {
|
|
106
|
+
sourceMap[source] = [settings, [item]];
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
sourceMap[source] = [null, []];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else if (data[0]) {
|
|
113
|
+
data[1].push(item);
|
|
114
|
+
}
|
|
117
115
|
}
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
}
|
|
117
|
+
for (const source in sourceMap) {
|
|
118
|
+
const [settings, commands] = sourceMap[source];
|
|
119
|
+
if (settings) {
|
|
120
|
+
for (let i = 0, length = commands.length, group, procedure; i < length; ++i) {
|
|
121
|
+
const item = commands[i];
|
|
122
|
+
const command = item.withCommand;
|
|
123
|
+
if (Array.isArray(command)) {
|
|
124
|
+
[group, procedure] = command;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
const { name, table } = item;
|
|
128
|
+
group = name && table ? name + ':' + table : table || name || (typeof item.document === 'string' ? item.document : '');
|
|
129
|
+
procedure = command;
|
|
130
|
+
}
|
|
131
|
+
const data = settings[group]?.[procedure];
|
|
132
|
+
if ((0, types_1.isPlainObject)(data)) {
|
|
133
|
+
if ('uri' in data) {
|
|
134
|
+
delete data.uri;
|
|
135
|
+
}
|
|
136
|
+
if ('credential' in data) {
|
|
137
|
+
delete data.credential;
|
|
138
|
+
}
|
|
139
|
+
if ('usePool' in data) {
|
|
140
|
+
delete data.usePool;
|
|
141
|
+
}
|
|
142
|
+
Object.assign(item, data);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
120
145
|
}
|
|
121
|
-
Object.assign(item, data);
|
|
122
146
|
}
|
|
123
147
|
}
|
|
124
148
|
async executeQuery(item, options) {
|
|
@@ -140,9 +164,9 @@ class Db extends core_1.ClientDb {
|
|
|
140
164
|
return this.getClient(batch[0].source).executeBatchQuery.call(this, batch, options, outResult);
|
|
141
165
|
}
|
|
142
166
|
async processRows(batch, tasks, parallel, outResult) {
|
|
143
|
-
let disconnect;
|
|
167
|
+
let errorAsEmpty, disconnect;
|
|
144
168
|
if ((0, types_1.isObject)(parallel)) {
|
|
145
|
-
({
|
|
169
|
+
({ parallel, errorAsEmpty, disconnect } = parallel);
|
|
146
170
|
}
|
|
147
171
|
const terminate = () => {
|
|
148
172
|
this.applyState(batch, 8);
|
|
@@ -158,8 +182,13 @@ class Db extends core_1.ClientDb {
|
|
|
158
182
|
this.applyState(batch, 16);
|
|
159
183
|
terminate();
|
|
160
184
|
if (outResult) {
|
|
161
|
-
|
|
162
|
-
outResult
|
|
185
|
+
if (errorAsEmpty) {
|
|
186
|
+
outResult.length = 0;
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
for (let i = 0, length = outResult.length; i < length; ++i) {
|
|
190
|
+
outResult[i] = null;
|
|
191
|
+
}
|
|
163
192
|
}
|
|
164
193
|
return outResult;
|
|
165
194
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/db",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.19",
|
|
4
4
|
"description": "DB modules for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/core": "0.11.
|
|
24
|
-
"@e-mc/request": "0.11.
|
|
25
|
-
"@e-mc/types": "0.11.
|
|
23
|
+
"@e-mc/core": "0.11.19",
|
|
24
|
+
"@e-mc/request": "0.11.19",
|
|
25
|
+
"@e-mc/types": "0.11.19"
|
|
26
26
|
}
|
|
27
27
|
}
|