@sprucelabs/data-stores 17.0.61 → 17.0.64
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.
|
@@ -15,7 +15,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.MONGO_TEST_URI = void 0;
|
|
18
|
-
const
|
|
18
|
+
const differenceWith_1 = __importDefault(require("lodash/differenceWith"));
|
|
19
|
+
const isEqual_1 = __importDefault(require("lodash/isEqual"));
|
|
19
20
|
const mongodb_1 = require("mongodb");
|
|
20
21
|
const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
|
|
21
22
|
const generateId_1 = __importDefault(require("../utilities/generateId"));
|
|
@@ -230,7 +231,7 @@ class MongoDatabase {
|
|
|
230
231
|
const indexes = await this.listIndexes(collection);
|
|
231
232
|
let found = false;
|
|
232
233
|
for (const index of indexes) {
|
|
233
|
-
if ((0,
|
|
234
|
+
if ((0, isEqual_1.default)(Object.keys(index.key), fields)) {
|
|
234
235
|
await this.assertDbWhileAttempingTo('drop a index.', collection)
|
|
235
236
|
.collection(collection)
|
|
236
237
|
.dropIndex(index.name);
|
|
@@ -305,7 +306,7 @@ class MongoDatabase {
|
|
|
305
306
|
}
|
|
306
307
|
doesIndexExist(currentIndexes, fields) {
|
|
307
308
|
for (const index of currentIndexes !== null && currentIndexes !== void 0 ? currentIndexes : []) {
|
|
308
|
-
if ((0,
|
|
309
|
+
if ((0, isEqual_1.default)(index, fields)) {
|
|
309
310
|
return true;
|
|
310
311
|
}
|
|
311
312
|
}
|
|
@@ -313,7 +314,7 @@ class MongoDatabase {
|
|
|
313
314
|
}
|
|
314
315
|
async syncIndexes(collectionName, indexes) {
|
|
315
316
|
const currentIndexes = await this.getIndexes(collectionName);
|
|
316
|
-
const extraIndexes = (0,
|
|
317
|
+
const extraIndexes = (0, differenceWith_1.default)(currentIndexes, indexes, isEqual_1.default).filter((i) => !(i.length === 1 && i[0] === '_id'));
|
|
317
318
|
for (const index of indexes) {
|
|
318
319
|
if (!this.doesIndexExist(currentIndexes, index)) {
|
|
319
320
|
await this.createIndex(collectionName, index);
|
|
@@ -349,7 +350,7 @@ class MongoDatabase {
|
|
|
349
350
|
}
|
|
350
351
|
async syncUniqueIndexes(collectionName, indexes) {
|
|
351
352
|
const currentIndexes = await this.getUniqueIndexes(collectionName);
|
|
352
|
-
const extraIndexes = (0,
|
|
353
|
+
const extraIndexes = (0, differenceWith_1.default)(currentIndexes, indexes, isEqual_1.default);
|
|
353
354
|
for (const index of indexes) {
|
|
354
355
|
if (!this.doesIndexExist(currentIndexes, index)) {
|
|
355
356
|
await this.createUniqueIndex(collectionName, index);
|
|
@@ -16,9 +16,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
var _a;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
19
|
-
const
|
|
19
|
+
const differenceWith_1 = __importDefault(require("lodash/differenceWith"));
|
|
20
20
|
const get_1 = __importDefault(require("lodash/get"));
|
|
21
|
+
const isEqual_1 = __importDefault(require("lodash/isEqual"));
|
|
21
22
|
const isObject_1 = __importDefault(require("lodash/isObject"));
|
|
23
|
+
const uniqBy_1 = __importDefault(require("lodash/uniqBy"));
|
|
22
24
|
const nedb_1 = __importDefault(require("nedb"));
|
|
23
25
|
const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
|
|
24
26
|
const AbstractMutexer_1 = __importDefault(require("../mutexers/AbstractMutexer"));
|
|
@@ -320,7 +322,7 @@ class NeDbDatabase extends AbstractMutexer_1.default {
|
|
|
320
322
|
let found = false;
|
|
321
323
|
let newIndexes = [];
|
|
322
324
|
for (const uniq of (_a = col._uniqueIndexes) !== null && _a !== void 0 ? _a : []) {
|
|
323
|
-
if (!(0,
|
|
325
|
+
if (!(0, isEqual_1.default)(uniq, fields)) {
|
|
324
326
|
newIndexes.push(uniq);
|
|
325
327
|
}
|
|
326
328
|
else {
|
|
@@ -334,7 +336,7 @@ class NeDbDatabase extends AbstractMutexer_1.default {
|
|
|
334
336
|
else {
|
|
335
337
|
newIndexes = [];
|
|
336
338
|
for (const index of (_b = col._indexes) !== null && _b !== void 0 ? _b : []) {
|
|
337
|
-
if (!(0,
|
|
339
|
+
if (!(0, isEqual_1.default)(index, fields)) {
|
|
338
340
|
newIndexes.push(index);
|
|
339
341
|
}
|
|
340
342
|
else {
|
|
@@ -355,7 +357,7 @@ class NeDbDatabase extends AbstractMutexer_1.default {
|
|
|
355
357
|
}
|
|
356
358
|
doesIndexExist(currentIndexes, fields) {
|
|
357
359
|
for (const index of currentIndexes !== null && currentIndexes !== void 0 ? currentIndexes : []) {
|
|
358
|
-
if ((0,
|
|
360
|
+
if ((0, isEqual_1.default)(index, fields)) {
|
|
359
361
|
return true;
|
|
360
362
|
}
|
|
361
363
|
}
|
|
@@ -381,7 +383,7 @@ class NeDbDatabase extends AbstractMutexer_1.default {
|
|
|
381
383
|
});
|
|
382
384
|
parsedExisting.push(tempDoc);
|
|
383
385
|
}
|
|
384
|
-
const uniqued = (0,
|
|
386
|
+
const uniqued = (0, uniqBy_1.default)(parsedExisting, JSON.stringify);
|
|
385
387
|
if (parsedExisting.length != uniqued.length) {
|
|
386
388
|
throw new SpruceError_1.default({
|
|
387
389
|
code: 'DUPLICATE_KEY',
|
|
@@ -404,7 +406,7 @@ class NeDbDatabase extends AbstractMutexer_1.default {
|
|
|
404
406
|
async syncUniqueIndexes(collectionName, indexes) {
|
|
405
407
|
var _a;
|
|
406
408
|
const currentIndexes = await this.getUniqueIndexes(collectionName);
|
|
407
|
-
const extraIndexes = (0,
|
|
409
|
+
const extraIndexes = (0, differenceWith_1.default)(currentIndexes, indexes, isEqual_1.default);
|
|
408
410
|
for (const index of indexes) {
|
|
409
411
|
if (!this.doesIndexExist(currentIndexes, index)) {
|
|
410
412
|
try {
|
|
@@ -424,7 +426,7 @@ class NeDbDatabase extends AbstractMutexer_1.default {
|
|
|
424
426
|
async syncIndexes(collectionName, indexes) {
|
|
425
427
|
var _a;
|
|
426
428
|
const currentIndexes = await this.getIndexes(collectionName);
|
|
427
|
-
const extraIndexes = (0,
|
|
429
|
+
const extraIndexes = (0, differenceWith_1.default)(currentIndexes, indexes, isEqual_1.default);
|
|
428
430
|
for (const index of indexes) {
|
|
429
431
|
if (!this.doesIndexExist(currentIndexes, index)) {
|
|
430
432
|
try {
|
|
@@ -18,7 +18,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
18
18
|
}
|
|
19
19
|
return t;
|
|
20
20
|
};
|
|
21
|
-
import
|
|
21
|
+
import differenceWith from 'lodash/differenceWith.js';
|
|
22
|
+
import isEqual from 'lodash/isEqual.js';
|
|
22
23
|
import { MongoClient, MongoError } from 'mongodb';
|
|
23
24
|
import SpruceError from '../errors/SpruceError.js';
|
|
24
25
|
import generateId from '../utilities/generateId.js';
|
|
@@ -20,9 +20,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
};
|
|
21
21
|
var _a;
|
|
22
22
|
import dotenv from 'dotenv';
|
|
23
|
-
import
|
|
23
|
+
import differenceWith from 'lodash/differenceWith.js';
|
|
24
24
|
import get from 'lodash/get.js';
|
|
25
|
+
import isEqual from 'lodash/isEqual.js';
|
|
25
26
|
import isObject from 'lodash/isObject.js';
|
|
27
|
+
import uniqBy from 'lodash/uniqBy.js';
|
|
26
28
|
import Datastore from 'nedb';
|
|
27
29
|
import SpruceError from '../errors/SpruceError.js';
|
|
28
30
|
import AbstractMutexer from '../mutexers/AbstractMutexer.js';
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "17.0.
|
|
6
|
+
"version": "17.0.64",
|
|
7
7
|
"files": [
|
|
8
8
|
"build/**/*",
|
|
9
9
|
"!build/__tests__",
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
"upgrade.packages.test": "yarn upgrade.packages.all && yarn lint && yarn build.dev && yarn test"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@sprucelabs/error": "^5.0.
|
|
76
|
-
"@sprucelabs/schema": "^28.3.
|
|
77
|
-
"@sprucelabs/spruce-skill-utils": "^26.3.
|
|
75
|
+
"@sprucelabs/error": "^5.0.488",
|
|
76
|
+
"@sprucelabs/schema": "^28.3.19",
|
|
77
|
+
"@sprucelabs/spruce-skill-utils": "^26.3.12",
|
|
78
78
|
"globby": "^11.0.4",
|
|
79
79
|
"just-clone": "^6.0.1",
|
|
80
80
|
"lodash": "^4.17.21",
|
|
@@ -82,13 +82,13 @@
|
|
|
82
82
|
"nedb": "^1.8.0"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
|
-
"@sprucelabs/esm-postbuild": "^1.0.
|
|
86
|
-
"@sprucelabs/jest-json-reporter": "^6.0.
|
|
87
|
-
"@sprucelabs/jest-sheets-reporter": "^1.3.
|
|
88
|
-
"@sprucelabs/resolve-path-aliases": "^1.1.
|
|
85
|
+
"@sprucelabs/esm-postbuild": "^1.0.533",
|
|
86
|
+
"@sprucelabs/jest-json-reporter": "^6.0.432",
|
|
87
|
+
"@sprucelabs/jest-sheets-reporter": "^1.3.67",
|
|
88
|
+
"@sprucelabs/resolve-path-aliases": "^1.1.76",
|
|
89
89
|
"@sprucelabs/semantic-release": "^4.0.8",
|
|
90
|
-
"@sprucelabs/test": "^7.7.
|
|
91
|
-
"@sprucelabs/test-utils": "^3.1.
|
|
90
|
+
"@sprucelabs/test": "^7.7.339",
|
|
91
|
+
"@sprucelabs/test-utils": "^3.1.40",
|
|
92
92
|
"@types/lodash": "^4.14.182",
|
|
93
93
|
"@types/nedb": "^1.8.12",
|
|
94
94
|
"@types/node": "17.0.5",
|