@sprucelabs/data-stores 26.4.89 → 27.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/build/.spruce/errors/dataStores/databaseNotConnected.schema.js +5 -5
- package/build/.spruce/errors/dataStores/duplicateKey.schema.js +1 -1
- package/build/.spruce/errors/dataStores/duplicateRecord.schema.js +9 -9
- package/build/.spruce/errors/dataStores/failedToLoadStore.schema.js +3 -3
- package/build/.spruce/errors/dataStores/failedToLoadStores.schema.js +5 -3
- package/build/.spruce/errors/dataStores/indexExists.schema.js +5 -5
- package/build/.spruce/errors/dataStores/indexNotFound.schema.js +5 -5
- package/build/.spruce/errors/dataStores/invalidConnectionStringScheme.schema.js +3 -3
- package/build/.spruce/errors/dataStores/invalidDatabaseName.schema.js +3 -3
- package/build/.spruce/errors/dataStores/invalidDbConnectionString.schema.js +1 -1
- package/build/.spruce/errors/dataStores/invalidFakeQueryResponse.schema.js +5 -5
- package/build/.spruce/errors/dataStores/invalidStore.schema copy.js +5 -5
- package/build/.spruce/errors/dataStores/invalidStore.schema.js +1 -1
- package/build/.spruce/errors/dataStores/invalidStoreName.schema.js +5 -5
- package/build/.spruce/errors/dataStores/mongoIdMappingError.schema.js +1 -1
- package/build/.spruce/errors/dataStores/notImplemented.schema.js +1 -1
- package/build/.spruce/errors/dataStores/queryNotFaked.schema.js +5 -5
- package/build/.spruce/errors/dataStores/record-not-found-query.schema.js +1 -1
- package/build/.spruce/errors/dataStores/recordNotFound.schema.js +5 -5
- package/build/.spruce/errors/dataStores/scrambleNotConfigured.schema.js +1 -1
- package/build/.spruce/errors/dataStores/unableToConnectToDb.schema.js +1 -1
- package/build/.spruce/errors/dataStores/unknownDatabaseError.schema.js +3 -3
- package/build/.spruce/errors/dataStores/unknownError.schema.js +1 -1
- package/build/.spruce/errors/dataStores/unknownStoreError.schema.js +5 -5
- package/build/.spruce/errors/errors.types.d.ts +53 -56
- package/build/.spruce/errors/errors.types.js +0 -2
- package/build/.spruce/errors/options.types.d.ts +2 -2
- package/build/.spruce/schemas/fields/fields.types.d.ts +1 -1
- package/build/cursors/BatchArrayCursor.d.ts +2 -2
- package/build/databases/MongoDatabase.js +3 -1
- package/build/databases/NeDbDatabase.js +9 -3
- package/build/databases/mongo.types.d.ts +89 -135
- package/build/databases/mongo.types.js +0 -1
- package/build/errors/SpruceError.d.ts +1 -1
- package/build/errors/SpruceError.js +6 -2
- package/build/errors/failedToLoadStores.builder.js +1 -1
- package/build/errors/mongoIdMappingError.builder.js +0 -2
- package/build/errors/scrambleNotConfigured.builder.js +0 -2
- package/build/esm/.spruce/errors/errors.types.d.ts +53 -56
- package/build/esm/.spruce/errors/errors.types.js +0 -2
- package/build/esm/.spruce/errors/options.types.d.ts +2 -2
- package/build/esm/cursors/BatchArrayCursor.d.ts +2 -2
- package/build/esm/databases/MongoDatabase.js +3 -1
- package/build/esm/databases/NeDbDatabase.js +9 -3
- package/build/esm/databases/mongo.types.d.ts +89 -135
- package/build/esm/databases/mongo.types.js +0 -1
- package/build/esm/errors/SpruceError.d.ts +1 -1
- package/build/esm/errors/SpruceError.js +6 -2
- package/build/esm/errors/failedToLoadStores.builder.js +1 -1
- package/build/esm/errors/mongoIdMappingError.builder.js +0 -2
- package/build/esm/errors/scrambleNotConfigured.builder.js +0 -2
- package/build/esm/loaders/StoreLoader.d.ts +1 -1
- package/build/esm/plugins/DatabaseFieldMapperPlugin.js +3 -1
- package/build/esm/stores/AbstractStore.js +4 -2
- package/build/esm/tests/AbstractDatabaseTest.js +3 -1
- package/build/esm/tests/databaseAssertUtil.js +66 -20
- package/build/esm/types/query.types.d.ts +4 -4
- package/build/esm/types/query.types.js +0 -1
- package/build/loaders/StoreLoader.d.ts +1 -1
- package/build/plugins/DatabaseFieldMapperPlugin.js +3 -1
- package/build/stores/AbstractStore.js +4 -2
- package/build/tests/AbstractDatabaseTest.js +3 -1
- package/build/tests/databaseAssertUtil.js +66 -20
- package/build/types/query.types.d.ts +4 -4
- package/build/types/query.types.js +0 -1
- package/package.json +17 -29
@@ -1,11 +1,13 @@
|
|
1
|
+
import AbstractSpruceError from '@sprucelabs/error';
|
1
2
|
import { default as SchemaEntity } from '@sprucelabs/schema';
|
2
3
|
import * as SpruceSchema from '@sprucelabs/schema';
|
4
|
+
import { FailedToLoadStoreErrorOptions } from './options.types';
|
3
5
|
export declare namespace SpruceErrors.DataStores {
|
4
6
|
interface UnknownStoreError {
|
5
7
|
/** Action. e.g. createPerson, updateLocation, etc */
|
6
|
-
|
8
|
+
action: string;
|
7
9
|
/** Store name. */
|
8
|
-
|
10
|
+
storeName: string;
|
9
11
|
}
|
10
12
|
interface UnknownStoreErrorSchema extends SpruceSchema.Schema {
|
11
13
|
id: 'unknownStoreError';
|
@@ -13,7 +15,7 @@ export declare namespace SpruceErrors.DataStores {
|
|
13
15
|
name: 'Unknown store error';
|
14
16
|
fields: {
|
15
17
|
/** Action. e.g. createPerson, updateLocation, etc */
|
16
|
-
|
18
|
+
action: {
|
17
19
|
label: 'Action';
|
18
20
|
type: 'text';
|
19
21
|
isRequired: true;
|
@@ -21,7 +23,7 @@ export declare namespace SpruceErrors.DataStores {
|
|
21
23
|
options: undefined;
|
22
24
|
};
|
23
25
|
/** Store name. */
|
24
|
-
|
26
|
+
storeName: {
|
25
27
|
label: 'Store name';
|
26
28
|
type: 'text';
|
27
29
|
isRequired: true;
|
@@ -44,7 +46,7 @@ export declare namespace SpruceErrors.DataStores {
|
|
44
46
|
}
|
45
47
|
export declare namespace SpruceErrors.DataStores {
|
46
48
|
interface UnknownDatabaseError {
|
47
|
-
|
49
|
+
databaseErrorMessage: string;
|
48
50
|
}
|
49
51
|
interface UnknownDatabaseErrorSchema extends SpruceSchema.Schema {
|
50
52
|
id: 'unknownDatabaseError';
|
@@ -52,7 +54,7 @@ export declare namespace SpruceErrors.DataStores {
|
|
52
54
|
name: 'unknown database error';
|
53
55
|
fields: {
|
54
56
|
/** . */
|
55
|
-
|
57
|
+
databaseErrorMessage: {
|
56
58
|
type: 'text';
|
57
59
|
isRequired: true;
|
58
60
|
options: undefined;
|
@@ -84,10 +86,7 @@ export declare namespace SpruceErrors.DataStores {
|
|
84
86
|
type ScrambleNotConfiguredEntity = SchemaEntity<SpruceErrors.DataStores.ScrambleNotConfiguredSchema>;
|
85
87
|
}
|
86
88
|
export declare namespace SpruceErrors.DataStores {
|
87
|
-
|
88
|
-
/** . */
|
89
|
-
[field: string]: (any) | undefined | null;
|
90
|
-
}
|
89
|
+
type RecordNotFoundQuery = Record<string, any | undefined | null>;
|
91
90
|
interface RecordNotFoundQuerySchema extends SpruceSchema.Schema {
|
92
91
|
id: 'record-not-found-query';
|
93
92
|
namespace: 'DataStores';
|
@@ -105,9 +104,9 @@ export declare namespace SpruceErrors.DataStores {
|
|
105
104
|
export declare namespace SpruceErrors.DataStores {
|
106
105
|
interface RecordNotFound {
|
107
106
|
/** Store name. */
|
108
|
-
|
107
|
+
storeName: string;
|
109
108
|
/** Query. */
|
110
|
-
|
109
|
+
query: SpruceErrors.DataStores.RecordNotFoundQuery;
|
111
110
|
}
|
112
111
|
interface RecordNotFoundSchema extends SpruceSchema.Schema {
|
113
112
|
id: 'recordNotFound';
|
@@ -115,14 +114,14 @@ export declare namespace SpruceErrors.DataStores {
|
|
115
114
|
name: 'Record not found';
|
116
115
|
fields: {
|
117
116
|
/** Store name. */
|
118
|
-
|
117
|
+
storeName: {
|
119
118
|
label: 'Store name';
|
120
119
|
type: 'text';
|
121
120
|
isRequired: true;
|
122
121
|
options: undefined;
|
123
122
|
};
|
124
123
|
/** Query. */
|
125
|
-
|
124
|
+
query: {
|
126
125
|
label: 'Query';
|
127
126
|
type: 'schema';
|
128
127
|
isRequired: true;
|
@@ -136,8 +135,8 @@ export declare namespace SpruceErrors.DataStores {
|
|
136
135
|
}
|
137
136
|
export declare namespace SpruceErrors.DataStores {
|
138
137
|
interface QueryNotFaked {
|
139
|
-
|
140
|
-
|
138
|
+
query: string;
|
139
|
+
params?: Record<string, any> | undefined | null;
|
141
140
|
}
|
142
141
|
interface QueryNotFakedSchema extends SpruceSchema.Schema {
|
143
142
|
id: 'queryNotFaked';
|
@@ -145,13 +144,13 @@ export declare namespace SpruceErrors.DataStores {
|
|
145
144
|
name: 'Query not faked';
|
146
145
|
fields: {
|
147
146
|
/** . */
|
148
|
-
|
147
|
+
query: {
|
149
148
|
type: 'text';
|
150
149
|
isRequired: true;
|
151
150
|
options: undefined;
|
152
151
|
};
|
153
152
|
/** . */
|
154
|
-
|
153
|
+
params: {
|
155
154
|
type: 'raw';
|
156
155
|
options: {
|
157
156
|
valueType: `Record<string, any>`;
|
@@ -185,8 +184,8 @@ export declare namespace SpruceErrors.DataStores {
|
|
185
184
|
}
|
186
185
|
export declare namespace SpruceErrors.DataStores {
|
187
186
|
interface InvalidStoreName {
|
188
|
-
|
189
|
-
|
187
|
+
suppliedName: string;
|
188
|
+
validNames: string[];
|
190
189
|
}
|
191
190
|
interface InvalidStoreNameSchema extends SpruceSchema.Schema {
|
192
191
|
id: 'invalidStoreName';
|
@@ -194,13 +193,13 @@ export declare namespace SpruceErrors.DataStores {
|
|
194
193
|
name: 'Invalid store';
|
195
194
|
fields: {
|
196
195
|
/** . */
|
197
|
-
|
196
|
+
suppliedName: {
|
198
197
|
type: 'text';
|
199
198
|
isRequired: true;
|
200
199
|
options: undefined;
|
201
200
|
};
|
202
201
|
/** . */
|
203
|
-
|
202
|
+
validNames: {
|
204
203
|
type: 'text';
|
205
204
|
isRequired: true;
|
206
205
|
isArray: true;
|
@@ -223,8 +222,8 @@ export declare namespace SpruceErrors.DataStores {
|
|
223
222
|
}
|
224
223
|
export declare namespace SpruceErrors.DataStores {
|
225
224
|
interface InvalidFakeQueryResponse {
|
226
|
-
|
227
|
-
|
225
|
+
query: string;
|
226
|
+
response: any;
|
228
227
|
}
|
229
228
|
interface InvalidFakeQueryResponseSchema extends SpruceSchema.Schema {
|
230
229
|
id: 'invalidFakeQueryResponse';
|
@@ -232,13 +231,13 @@ export declare namespace SpruceErrors.DataStores {
|
|
232
231
|
name: 'Invalid fake query response';
|
233
232
|
fields: {
|
234
233
|
/** . */
|
235
|
-
|
234
|
+
query: {
|
236
235
|
type: 'text';
|
237
236
|
isRequired: true;
|
238
237
|
options: undefined;
|
239
238
|
};
|
240
239
|
/** . */
|
241
|
-
|
240
|
+
response: {
|
242
241
|
type: 'raw';
|
243
242
|
isRequired: true;
|
244
243
|
options: {
|
@@ -262,7 +261,7 @@ export declare namespace SpruceErrors.DataStores {
|
|
262
261
|
}
|
263
262
|
export declare namespace SpruceErrors.DataStores {
|
264
263
|
interface InvalidDatabaseName {
|
265
|
-
|
264
|
+
suppliedName: string;
|
266
265
|
}
|
267
266
|
interface InvalidDatabaseNameSchema extends SpruceSchema.Schema {
|
268
267
|
id: 'invalidDatabaseName';
|
@@ -270,7 +269,7 @@ export declare namespace SpruceErrors.DataStores {
|
|
270
269
|
name: 'Invalid database name';
|
271
270
|
fields: {
|
272
271
|
/** . */
|
273
|
-
|
272
|
+
suppliedName: {
|
274
273
|
type: 'text';
|
275
274
|
isRequired: true;
|
276
275
|
options: undefined;
|
@@ -281,7 +280,7 @@ export declare namespace SpruceErrors.DataStores {
|
|
281
280
|
}
|
282
281
|
export declare namespace SpruceErrors.DataStores {
|
283
282
|
interface InvalidConnectionStringScheme {
|
284
|
-
|
283
|
+
connectionString: string;
|
285
284
|
}
|
286
285
|
interface InvalidConnectionStringSchemeSchema extends SpruceSchema.Schema {
|
287
286
|
id: 'invalidConnectionStringScheme';
|
@@ -289,7 +288,7 @@ export declare namespace SpruceErrors.DataStores {
|
|
289
288
|
name: 'Invalid connection string scheme';
|
290
289
|
fields: {
|
291
290
|
/** . */
|
292
|
-
|
291
|
+
connectionString: {
|
293
292
|
type: 'text';
|
294
293
|
isRequired: true;
|
295
294
|
options: undefined;
|
@@ -301,8 +300,8 @@ export declare namespace SpruceErrors.DataStores {
|
|
301
300
|
export declare namespace SpruceErrors.DataStores {
|
302
301
|
interface IndexNotFound {
|
303
302
|
/** Missing Index. */
|
304
|
-
|
305
|
-
|
303
|
+
missingIndex: string[];
|
304
|
+
collectionName: string;
|
306
305
|
}
|
307
306
|
interface IndexNotFoundSchema extends SpruceSchema.Schema {
|
308
307
|
id: 'indexNotFound';
|
@@ -310,7 +309,7 @@ export declare namespace SpruceErrors.DataStores {
|
|
310
309
|
name: 'Index not found';
|
311
310
|
fields: {
|
312
311
|
/** Missing Index. */
|
313
|
-
|
312
|
+
missingIndex: {
|
314
313
|
label: 'Missing Index';
|
315
314
|
type: 'text';
|
316
315
|
isRequired: true;
|
@@ -318,7 +317,7 @@ export declare namespace SpruceErrors.DataStores {
|
|
318
317
|
options: undefined;
|
319
318
|
};
|
320
319
|
/** . */
|
321
|
-
|
320
|
+
collectionName: {
|
322
321
|
type: 'text';
|
323
322
|
isRequired: true;
|
324
323
|
options: undefined;
|
@@ -330,8 +329,8 @@ export declare namespace SpruceErrors.DataStores {
|
|
330
329
|
export declare namespace SpruceErrors.DataStores {
|
331
330
|
interface IndexExists {
|
332
331
|
/** Index Exists. */
|
333
|
-
|
334
|
-
|
332
|
+
index: string[];
|
333
|
+
collectionName: string;
|
335
334
|
}
|
336
335
|
interface IndexExistsSchema extends SpruceSchema.Schema {
|
337
336
|
id: 'indexExists';
|
@@ -339,7 +338,7 @@ export declare namespace SpruceErrors.DataStores {
|
|
339
338
|
name: 'Index Exists';
|
340
339
|
fields: {
|
341
340
|
/** Index Exists. */
|
342
|
-
|
341
|
+
index: {
|
343
342
|
label: 'Index Exists';
|
344
343
|
type: 'text';
|
345
344
|
isRequired: true;
|
@@ -347,7 +346,7 @@ export declare namespace SpruceErrors.DataStores {
|
|
347
346
|
options: undefined;
|
348
347
|
};
|
349
348
|
/** . */
|
350
|
-
|
349
|
+
collectionName: {
|
351
350
|
type: 'text';
|
352
351
|
isRequired: true;
|
353
352
|
options: undefined;
|
@@ -356,11 +355,9 @@ export declare namespace SpruceErrors.DataStores {
|
|
356
355
|
}
|
357
356
|
type IndexExistsEntity = SchemaEntity<SpruceErrors.DataStores.IndexExistsSchema>;
|
358
357
|
}
|
359
|
-
import AbstractSpruceError from '@sprucelabs/error';
|
360
|
-
import { FailedToLoadStoreErrorOptions } from "./options.types";
|
361
358
|
export declare namespace SpruceErrors.DataStores {
|
362
359
|
interface FailedToLoadStores {
|
363
|
-
|
360
|
+
errors: AbstractSpruceError<FailedToLoadStoreErrorOptions>[];
|
364
361
|
}
|
365
362
|
interface FailedToLoadStoresSchema extends SpruceSchema.Schema {
|
366
363
|
id: 'failedToLoadStores';
|
@@ -368,7 +365,7 @@ export declare namespace SpruceErrors.DataStores {
|
|
368
365
|
name: 'failed to load stores';
|
369
366
|
fields: {
|
370
367
|
/** . */
|
371
|
-
|
368
|
+
errors: {
|
372
369
|
type: 'raw';
|
373
370
|
isRequired: true;
|
374
371
|
isArray: true;
|
@@ -382,7 +379,7 @@ export declare namespace SpruceErrors.DataStores {
|
|
382
379
|
}
|
383
380
|
export declare namespace SpruceErrors.DataStores {
|
384
381
|
interface FailedToLoadStore {
|
385
|
-
|
382
|
+
name: string;
|
386
383
|
}
|
387
384
|
interface FailedToLoadStoreSchema extends SpruceSchema.Schema {
|
388
385
|
id: 'failedToLoadStore';
|
@@ -390,7 +387,7 @@ export declare namespace SpruceErrors.DataStores {
|
|
390
387
|
name: 'Failed to load store';
|
391
388
|
fields: {
|
392
389
|
/** . */
|
393
|
-
|
390
|
+
name: {
|
394
391
|
type: 'text';
|
395
392
|
isRequired: true;
|
396
393
|
options: undefined;
|
@@ -401,11 +398,11 @@ export declare namespace SpruceErrors.DataStores {
|
|
401
398
|
}
|
402
399
|
export declare namespace SpruceErrors.DataStores {
|
403
400
|
interface DuplicateRecord {
|
404
|
-
|
405
|
-
|
406
|
-
|
401
|
+
duplicateFields: string[];
|
402
|
+
duplicateValues: string[];
|
403
|
+
collectionName: string;
|
407
404
|
/** Action. e.g. create, update, etc. */
|
408
|
-
|
405
|
+
action: string;
|
409
406
|
}
|
410
407
|
interface DuplicateRecordSchema extends SpruceSchema.Schema {
|
411
408
|
id: 'duplicateRecord';
|
@@ -413,27 +410,27 @@ export declare namespace SpruceErrors.DataStores {
|
|
413
410
|
name: 'Duplicate record';
|
414
411
|
fields: {
|
415
412
|
/** . */
|
416
|
-
|
413
|
+
duplicateFields: {
|
417
414
|
type: 'text';
|
418
415
|
isRequired: true;
|
419
416
|
isArray: true;
|
420
417
|
options: undefined;
|
421
418
|
};
|
422
419
|
/** . */
|
423
|
-
|
420
|
+
duplicateValues: {
|
424
421
|
type: 'text';
|
425
422
|
isRequired: true;
|
426
423
|
isArray: true;
|
427
424
|
options: undefined;
|
428
425
|
};
|
429
426
|
/** . */
|
430
|
-
|
427
|
+
collectionName: {
|
431
428
|
type: 'text';
|
432
429
|
isRequired: true;
|
433
430
|
options: undefined;
|
434
431
|
};
|
435
432
|
/** Action. e.g. create, update, etc. */
|
436
|
-
|
433
|
+
action: {
|
437
434
|
label: 'Action';
|
438
435
|
type: 'text';
|
439
436
|
isRequired: true;
|
@@ -457,8 +454,8 @@ export declare namespace SpruceErrors.DataStores {
|
|
457
454
|
}
|
458
455
|
export declare namespace SpruceErrors.DataStores {
|
459
456
|
interface DatabaseNotConnected {
|
460
|
-
|
461
|
-
|
457
|
+
operationAttempted: string;
|
458
|
+
collectionName?: string | undefined | null;
|
462
459
|
}
|
463
460
|
interface DatabaseNotConnectedSchema extends SpruceSchema.Schema {
|
464
461
|
id: 'databaseNotConnected';
|
@@ -466,13 +463,13 @@ export declare namespace SpruceErrors.DataStores {
|
|
466
463
|
name: 'Database not connected';
|
467
464
|
fields: {
|
468
465
|
/** . */
|
469
|
-
|
466
|
+
operationAttempted: {
|
470
467
|
type: 'text';
|
471
468
|
isRequired: true;
|
472
469
|
options: undefined;
|
473
470
|
};
|
474
471
|
/** . */
|
475
|
-
|
472
|
+
collectionName: {
|
476
473
|
type: 'text';
|
477
474
|
options: undefined;
|
478
475
|
};
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
1
|
+
import { ErrorOptions as ISpruceErrorOptions } from '@sprucelabs/error';
|
2
|
+
import { SpruceErrors } from './errors.types';
|
3
3
|
export interface UnknownStoreErrorErrorOptions extends SpruceErrors.DataStores.UnknownStoreError, ISpruceErrorOptions {
|
4
4
|
code: 'UNKNOWN_STORE_ERROR';
|
5
5
|
}
|
@@ -10,6 +10,6 @@ export default class BatchArrayCursor<T> implements BatchCursor<T> {
|
|
10
10
|
next(): Promise<T[] | null>;
|
11
11
|
[Symbol.asyncIterator](): AsyncIterator<T, T, undefined>;
|
12
12
|
}
|
13
|
-
export
|
13
|
+
export interface BatchArrayCursorOptions {
|
14
14
|
batchSize?: number;
|
15
|
-
}
|
15
|
+
}
|
@@ -207,7 +207,9 @@ export default class MongoDatabase {
|
|
207
207
|
}
|
208
208
|
catch (err) {
|
209
209
|
if (err.name === 'MongoParseError') {
|
210
|
-
throw new SpruceError({
|
210
|
+
throw new SpruceError({
|
211
|
+
code: 'INVALID_DB_CONNECTION_STRING',
|
212
|
+
});
|
211
213
|
}
|
212
214
|
else if (err.message.includes('ECONNREFUSED')) {
|
213
215
|
throw new SpruceError({ code: 'UNABLE_TO_CONNECT_TO_DB' });
|
@@ -71,7 +71,9 @@ export default class NeDbDatabase extends AbstractMutexer {
|
|
71
71
|
withId._id = withId.id;
|
72
72
|
delete withId.id;
|
73
73
|
}
|
74
|
-
const nullsToPlaceholder = this.handlePlaceholders(withId, NULL_PLACEHOLDER, (val) => val === null ||
|
74
|
+
const nullsToPlaceholder = this.handlePlaceholders(withId, NULL_PLACEHOLDER, (val) => val === null ||
|
75
|
+
typeof val === 'undefined' ||
|
76
|
+
val === NULL_PLACEHOLDER);
|
75
77
|
const undefinedToPlaceholder = this.handlePlaceholders(nullsToPlaceholder, UNDEFINED_PLACEHOLDER, (val) => val === undefined || val === UNDEFINED_PLACEHOLDER);
|
76
78
|
return undefinedToPlaceholder;
|
77
79
|
}
|
@@ -277,7 +279,9 @@ export default class NeDbDatabase extends AbstractMutexer {
|
|
277
279
|
}));
|
278
280
|
}
|
279
281
|
else {
|
280
|
-
resolve(docs
|
282
|
+
resolve(docs
|
283
|
+
? this.normalizeRecord(docs, neDbOptions)
|
284
|
+
: numUpdated);
|
281
285
|
}
|
282
286
|
}));
|
283
287
|
});
|
@@ -324,7 +328,9 @@ export default class NeDbDatabase extends AbstractMutexer {
|
|
324
328
|
yield this.randomDelay();
|
325
329
|
if (col._uniqueIndexes) {
|
326
330
|
for (const fields of col._uniqueIndexes) {
|
327
|
-
const existing = query
|
331
|
+
const existing = query
|
332
|
+
? yield this.findOne(collection, query)
|
333
|
+
: null;
|
328
334
|
const q = {};
|
329
335
|
const duplicateFields = [];
|
330
336
|
const duplicateValues = [];
|