@sprucelabs/data-stores 18.1.96 → 18.1.98

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.
@@ -14,6 +14,12 @@ const indexExistsSchema = {
14
14
  isArray: true,
15
15
  options: undefined
16
16
  },
17
+ /** . */
18
+ 'collectionName': {
19
+ type: 'text',
20
+ isRequired: true,
21
+ options: undefined
22
+ },
17
23
  }
18
24
  };
19
25
  schema_1.SchemaRegistry.getInstance().trackSchema(indexExistsSchema);
@@ -239,6 +239,7 @@ export declare namespace SpruceErrors.DataStores {
239
239
  interface IndexExists {
240
240
  /** Index Exists. */
241
241
  'index': string[];
242
+ 'collectionName': string;
242
243
  }
243
244
  interface IndexExistsSchema extends SpruceSchema.Schema {
244
245
  id: 'indexExists';
@@ -253,6 +254,12 @@ export declare namespace SpruceErrors.DataStores {
253
254
  isArray: true;
254
255
  options: undefined;
255
256
  };
257
+ /** . */
258
+ 'collectionName': {
259
+ type: 'text';
260
+ isRequired: true;
261
+ options: undefined;
262
+ };
256
263
  };
257
264
  }
258
265
  type IndexExistsEntity = SchemaEntity<SpruceErrors.DataStores.IndexExistsSchema>;
@@ -301,7 +301,11 @@ class MongoDatabase {
301
301
  }
302
302
  assertIndexDoesNotExist(currentIndexes, fields) {
303
303
  if (this.doesIndexExist(currentIndexes, fields)) {
304
- throw new SpruceError_1.default({ code: 'INDEX_EXISTS', index: fields });
304
+ throw new SpruceError_1.default({
305
+ code: 'INDEX_EXISTS',
306
+ index: fields,
307
+ collectionName: this.dbName,
308
+ });
305
309
  }
306
310
  }
307
311
  doesIndexExist(currentIndexes, fields) {
@@ -350,9 +350,13 @@ class NeDbDatabase extends AbstractMutexer_1.default {
350
350
  }
351
351
  throw new SpruceError_1.default({ code: 'INDEX_NOT_FOUND', missingIndex: fields });
352
352
  }
353
- assertIndexDoesNotExist(currentIndexes, fields) {
353
+ assertIndexDoesNotExist(currentIndexes, fields, collectionName) {
354
354
  if (this.doesIndexExist(currentIndexes, fields)) {
355
- throw new SpruceError_1.default({ code: 'INDEX_EXISTS', index: fields });
355
+ throw new SpruceError_1.default({
356
+ code: 'INDEX_EXISTS',
357
+ index: fields,
358
+ collectionName,
359
+ });
356
360
  }
357
361
  }
358
362
  doesIndexExist(currentIndexes, fields) {
@@ -369,7 +373,7 @@ class NeDbDatabase extends AbstractMutexer_1.default {
369
373
  col._uniqueIndexes = [];
370
374
  }
371
375
  await this.randomDelay();
372
- this.assertIndexDoesNotExist(col._uniqueIndexes, fields);
376
+ this.assertIndexDoesNotExist(col._uniqueIndexes, fields, collection);
373
377
  if (col._uniqueIndexes) {
374
378
  const tempUniqueIndexes = [...col._uniqueIndexes];
375
379
  tempUniqueIndexes.push(fields);
@@ -400,7 +404,7 @@ class NeDbDatabase extends AbstractMutexer_1.default {
400
404
  col._indexes = [];
401
405
  }
402
406
  await this.randomDelay();
403
- this.assertIndexDoesNotExist(col._indexes, fields);
407
+ this.assertIndexDoesNotExist(col._indexes, fields, collection);
404
408
  col._indexes.push(fields);
405
409
  }
406
410
  async syncUniqueIndexes(collectionName, indexes) {
@@ -85,7 +85,7 @@ If you are on a mac, using brew is recommended: https://brew.sh`;
85
85
  message = `The unique index ${options.missingIndex.join(', ')} you tried to remove does not exist!`;
86
86
  break;
87
87
  case 'INDEX_EXISTS':
88
- message = `The unique index ${options.index.join(', ')} you attempted to create already exists!`;
88
+ message = `The unique index ${options.index.join(', ')} you attempted to create in '${options.collectionName}' already exists!`;
89
89
  break;
90
90
  case 'UNKNOWN_ERROR':
91
91
  message = 'Unknown error!';
@@ -9,6 +9,10 @@ declare const _default: {
9
9
  isArray: true;
10
10
  isRequired: true;
11
11
  };
12
+ collectionName: {
13
+ type: "text";
14
+ isRequired: true;
15
+ };
12
16
  };
13
17
  };
14
18
  export default _default;
@@ -12,5 +12,9 @@ exports.default = (0, schema_1.buildErrorSchema)({
12
12
  isArray: true,
13
13
  isRequired: true,
14
14
  },
15
+ collectionName: {
16
+ type: 'text',
17
+ isRequired: true,
18
+ },
15
19
  },
16
20
  });
@@ -239,6 +239,7 @@ export declare namespace SpruceErrors.DataStores {
239
239
  interface IndexExists {
240
240
  /** Index Exists. */
241
241
  'index': string[];
242
+ 'collectionName': string;
242
243
  }
243
244
  interface IndexExistsSchema extends SpruceSchema.Schema {
244
245
  id: 'indexExists';
@@ -253,6 +254,12 @@ export declare namespace SpruceErrors.DataStores {
253
254
  isArray: true;
254
255
  options: undefined;
255
256
  };
257
+ /** . */
258
+ 'collectionName': {
259
+ type: 'text';
260
+ isRequired: true;
261
+ options: undefined;
262
+ };
256
263
  };
257
264
  }
258
265
  type IndexExistsEntity = SchemaEntity<SpruceErrors.DataStores.IndexExistsSchema>;
@@ -334,7 +334,11 @@ export default class MongoDatabase {
334
334
  }
335
335
  assertIndexDoesNotExist(currentIndexes, fields) {
336
336
  if (this.doesIndexExist(currentIndexes, fields)) {
337
- throw new SpruceError({ code: 'INDEX_EXISTS', index: fields });
337
+ throw new SpruceError({
338
+ code: 'INDEX_EXISTS',
339
+ index: fields,
340
+ collectionName: this.dbName,
341
+ });
338
342
  }
339
343
  }
340
344
  doesIndexExist(currentIndexes, fields) {
@@ -392,9 +392,13 @@ export default class NeDbDatabase extends AbstractMutexer {
392
392
  throw new SpruceError({ code: 'INDEX_NOT_FOUND', missingIndex: fields });
393
393
  });
394
394
  }
395
- assertIndexDoesNotExist(currentIndexes, fields) {
395
+ assertIndexDoesNotExist(currentIndexes, fields, collectionName) {
396
396
  if (this.doesIndexExist(currentIndexes, fields)) {
397
- throw new SpruceError({ code: 'INDEX_EXISTS', index: fields });
397
+ throw new SpruceError({
398
+ code: 'INDEX_EXISTS',
399
+ index: fields,
400
+ collectionName,
401
+ });
398
402
  }
399
403
  }
400
404
  doesIndexExist(currentIndexes, fields) {
@@ -412,7 +416,7 @@ export default class NeDbDatabase extends AbstractMutexer {
412
416
  col._uniqueIndexes = [];
413
417
  }
414
418
  yield this.randomDelay();
415
- this.assertIndexDoesNotExist(col._uniqueIndexes, fields);
419
+ this.assertIndexDoesNotExist(col._uniqueIndexes, fields, collection);
416
420
  if (col._uniqueIndexes) {
417
421
  const tempUniqueIndexes = [...col._uniqueIndexes];
418
422
  tempUniqueIndexes.push(fields);
@@ -445,7 +449,7 @@ export default class NeDbDatabase extends AbstractMutexer {
445
449
  col._indexes = [];
446
450
  }
447
451
  yield this.randomDelay();
448
- this.assertIndexDoesNotExist(col._indexes, fields);
452
+ this.assertIndexDoesNotExist(col._indexes, fields, collection);
449
453
  col._indexes.push(fields);
450
454
  });
451
455
  }
@@ -80,7 +80,7 @@ If you are on a mac, using brew is recommended: https://brew.sh`;
80
80
  message = `The unique index ${options.missingIndex.join(', ')} you tried to remove does not exist!`;
81
81
  break;
82
82
  case 'INDEX_EXISTS':
83
- message = `The unique index ${options.index.join(', ')} you attempted to create already exists!`;
83
+ message = `The unique index ${options.index.join(', ')} you attempted to create in '${options.collectionName}' already exists!`;
84
84
  break;
85
85
  case 'UNKNOWN_ERROR':
86
86
  message = 'Unknown error!';
@@ -9,6 +9,10 @@ declare const _default: {
9
9
  isArray: true;
10
10
  isRequired: true;
11
11
  };
12
+ collectionName: {
13
+ type: "text";
14
+ isRequired: true;
15
+ };
12
16
  };
13
17
  };
14
18
  export default _default;
@@ -10,5 +10,9 @@ export default buildErrorSchema({
10
10
  isArray: true,
11
11
  isRequired: true,
12
12
  },
13
+ collectionName: {
14
+ type: 'text',
15
+ isRequired: true,
16
+ },
13
17
  },
14
18
  });
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "18.1.96",
6
+ "version": "18.1.98",
7
7
  "files": [
8
8
  "build/**/*",
9
9
  "!build/__tests__",
@@ -74,7 +74,7 @@
74
74
  "dependencies": {
75
75
  "@sprucelabs/error": "^5.0.523",
76
76
  "@sprucelabs/schema": "^28.5.35",
77
- "@sprucelabs/spruce-skill-utils": "^26.4.130",
77
+ "@sprucelabs/spruce-skill-utils": "^26.4.131",
78
78
  "globby": "^11.0.4",
79
79
  "just-clone": "^6.1.1",
80
80
  "lodash": "^4.17.21",