@sprucelabs/data-stores 28.1.333 → 28.1.335

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.
@@ -98,6 +98,7 @@ const databaseAssertUtil = {
98
98
  'assertSyncIndexesHandlesRaceConditions',
99
99
  'assertSyncIndexesDoesNotRemoveExisting',
100
100
  'assertDuplicateFieldsWithMultipleUniqueIndexesWorkAsExpected',
101
+ 'assertCanSyncIndexesWithoutPartialThenAgainWithProperlyUpdates',
101
102
  ];
102
103
  const db = yield connectToDabatase(connect);
103
104
  yield db.dropDatabase();
@@ -117,14 +118,13 @@ const databaseAssertUtil = {
117
118
  }
118
119
  });
119
120
  },
120
- _getFilteredIndexes(db) {
121
+ _getIndexesWith_IdFilteredOut(db) {
121
122
  return __awaiter(this, void 0, void 0, function* () {
122
- return this._filterIdIndex(yield db.getIndexes(this.collectionName));
123
+ return this._filterOut_Id(yield db.getIndexes(this.collectionName));
123
124
  });
124
125
  },
125
- _filterIdIndex(allIndexes) {
126
- //@ts-ignore
127
- return allIndexes.filter((i) => i[0] !== '_id');
126
+ _filterOut_Id(allIndexes) {
127
+ return allIndexes.filter((i) => i.fields[0] !== '_id');
128
128
  },
129
129
  _assertUpdateUpdatedRightNumberOfRecords(db, search, updates, expectedUpdateCount) {
130
130
  return __awaiter(this, void 0, void 0, function* () {
@@ -247,20 +247,20 @@ const databaseAssertUtil = {
247
247
  yield db.createUniqueIndex(this.collectionName, ['uniqueField']);
248
248
  let indexes = (yield db.getUniqueIndexes(this.collectionName));
249
249
  assert.isLength(indexes, 1, 'getUniqueIndexes() did not return the unique index I tried to create!');
250
- assert.isLength(indexes[0], 1, 'getUniqueIndexes() needs to return an array of arrays. Each item in the array should be an array of fields that make up the unique index.');
251
- assert.isEqual(indexes[0][0].toLowerCase(), 'uniqueField'.toLowerCase(), 'getUniqueIndexes() did not add the expected field to the first unique index.');
250
+ assert.isLength(indexes[0].fields, 1, 'getUniqueIndexes() needs to return an array of IndexWithFilters. Each item in the array should be an array of fields that make up the unique index.');
251
+ assert.isEqual(indexes[0].fields[0].toLowerCase(), 'uniqueField'.toLowerCase(), 'getUniqueIndexes() did not add the expected field to the first unique index.');
252
252
  yield db.createUniqueIndex(this.collectionName, ['uniqueField2']);
253
- indexes = (yield db.getUniqueIndexes(this.collectionName));
253
+ indexes = yield db.getUniqueIndexes(this.collectionName);
254
254
  assert.isLength(indexes, 2);
255
- assert.isEqual(indexes[1][0].toLowerCase(), 'uniqueField2'.toLowerCase());
255
+ assert.isEqual(indexes[1].fields[0].toLowerCase(), 'uniqueField2'.toLowerCase());
256
256
  yield db.createUniqueIndex(this.collectionName, [
257
257
  'uniqueField3',
258
258
  'uniqueField4',
259
259
  ]);
260
- indexes = (yield db.getUniqueIndexes(this.collectionName));
260
+ indexes = yield db.getUniqueIndexes(this.collectionName);
261
261
  assert.isLength(indexes, 3);
262
- assert.isEqual(indexes[2][0].toLowerCase(), 'uniqueField3'.toLowerCase());
263
- assert.isEqual(indexes[2][1].toLowerCase(), 'uniqueField4'.toLowerCase());
262
+ assert.isEqual(indexes[2].fields[0].toLowerCase(), 'uniqueField3'.toLowerCase());
263
+ assert.isEqual(indexes[2].fields[1].toLowerCase(), 'uniqueField4'.toLowerCase());
264
264
  yield this.shutdown(db);
265
265
  });
266
266
  },
@@ -748,12 +748,12 @@ const databaseAssertUtil = {
748
748
  ['someField'],
749
749
  ['otherField', 'otherField2'],
750
750
  ]);
751
- let indexes = (yield db.getUniqueIndexes(this.collectionName));
751
+ let indexes = yield db.getUniqueIndexes(this.collectionName);
752
752
  assert.isLength(indexes, 3, 'syncUniqueIndexes() should have created 3 indexes.');
753
753
  yield db.syncUniqueIndexes(this.collectionName, [['uniqueField']]);
754
- indexes = (yield db.getUniqueIndexes(this.collectionName));
754
+ indexes = yield db.getUniqueIndexes(this.collectionName);
755
755
  assert.isLength(indexes, 1);
756
- assert.isEqual(indexes[0][0].toLowerCase(), 'uniquefield');
756
+ assert.isEqual(indexes[0].fields[0].toLowerCase(), 'uniquefield');
757
757
  yield db.syncUniqueIndexes(this.collectionName, [
758
758
  {
759
759
  fields: ['uniqueField'],
@@ -770,7 +770,7 @@ const databaseAssertUtil = {
770
770
  filter: { isActive: true },
771
771
  },
772
772
  ]);
773
- indexes = (yield db.getUniqueIndexes(this.collectionName));
773
+ indexes = yield db.getUniqueIndexes(this.collectionName);
774
774
  assert.isLength(indexes, 2, `Syncing unique indexs with filter is not removing extra indexes.`);
775
775
  yield this.shutdown(db);
776
776
  });
@@ -799,7 +799,7 @@ const databaseAssertUtil = {
799
799
  assert.isLength(indexes, 1, 'There should be 1 index after syncing.');
800
800
  yield db.syncUniqueIndexes(this.collectionName, [['someField']]);
801
801
  indexes = yield db.getUniqueIndexes(this.collectionName);
802
- assert.isLength(indexes, 1, 'There should now be 2 indexes after syncing.');
802
+ assert.isLength(indexes, 1, 'syncUniqueIndexes() should have removed the index that was set before it that was different.');
803
803
  yield db.syncUniqueIndexes(this.collectionName, [
804
804
  ['uniqueField'],
805
805
  ['someField'],
@@ -816,11 +816,11 @@ const databaseAssertUtil = {
816
816
  'someField',
817
817
  'someOtherField',
818
818
  ]);
819
- const err = yield assert.doesThrowAsync(() => db.dropIndex(this.collectionName, ['uniqueField', 'someOtherField']));
819
+ const err = yield assert.doesThrowAsync(() => db.dropIndex(this.collectionName, ['someOtherField', 'uniqueField']));
820
820
  lowerCaseMissingIndexValues(err);
821
821
  errorAssert.assertError(err, 'INDEX_NOT_FOUND', {
822
822
  collectionName: this.collectionName,
823
- missingIndex: ['uniquefield', 'someotherfield'],
823
+ missingIndex: ['someotherfield', 'uniquefield'],
824
824
  });
825
825
  yield this.shutdown(db);
826
826
  });
@@ -893,6 +893,7 @@ const databaseAssertUtil = {
893
893
  return __awaiter(this, void 0, void 0, function* () {
894
894
  const db = yield connectToDabatase(connect);
895
895
  yield assertCantCreateUniqueIndexTwice(db, this.collectionName, ['uniqueField'], 1);
896
+ yield assertCantCreateUniqueIndexTwice(db, this.collectionName, ['uniqueField', 'anotherField'], 2);
896
897
  yield this.shutdown(db);
897
898
  });
898
899
  },
@@ -1023,8 +1024,8 @@ const databaseAssertUtil = {
1023
1024
  }));
1024
1025
  errorAssert.assertError(err, 'DUPLICATE_RECORD', {
1025
1026
  collectionName: this.collectionName,
1026
- duplicateFields: ['target.organizationId', 'slug'],
1027
- duplicateValues: ['go!', 'a slug'],
1027
+ duplicateFields: ['slug', 'target.organizationId'],
1028
+ duplicateValues: ['a slug', 'go!'],
1028
1029
  action: 'create',
1029
1030
  });
1030
1031
  yield db.upsertOne(this.collectionName, {
@@ -1502,7 +1503,7 @@ const databaseAssertUtil = {
1502
1503
  uniqueField: 'test',
1503
1504
  slug: null,
1504
1505
  someField3: 'test',
1505
- }), undefined, `Creating a duplicate record with should throw an error.`);
1506
+ }), undefined, `Creating a duplicate record with should throw an error with a uniqueIndex with filter. Make sure syncUniqueIndexes() is actually created the index honoring the filter.`);
1506
1507
  yield db.createOne(this.collectionName, {
1507
1508
  name: generateId(),
1508
1509
  slug: '555-000-0000',
@@ -1596,6 +1597,56 @@ const databaseAssertUtil = {
1596
1597
  yield this.shutdown(db);
1597
1598
  });
1598
1599
  },
1600
+ assertCanSyncIndexesWithoutPartialThenAgainWithProperlyUpdates(connect) {
1601
+ return __awaiter(this, void 0, void 0, function* () {
1602
+ const db = yield connectToDabatase(connect);
1603
+ yield db.syncUniqueIndexes(this.collectionName, [
1604
+ ['uniqueField', 'someField3'],
1605
+ ]);
1606
+ yield db.syncUniqueIndexes(this.collectionName, [
1607
+ {
1608
+ fields: ['uniqueField', 'someField3'],
1609
+ filter: {
1610
+ uniqueField: { $type: 'string' },
1611
+ },
1612
+ },
1613
+ ]);
1614
+ yield db.createOne(this.collectionName, {
1615
+ name: generateId(),
1616
+ uniqueField: 1,
1617
+ slug: null,
1618
+ someField3: 'test',
1619
+ });
1620
+ try {
1621
+ yield db.createOne(this.collectionName, {
1622
+ name: generateId(),
1623
+ uniqueField: 1,
1624
+ slug: null,
1625
+ someField3: 'test',
1626
+ });
1627
+ }
1628
+ catch (_a) {
1629
+ assert.fail(`An error was thrown trying to create a record that should not have matched on a unique index with a filter. Make sure your database adapter is properly syncing indexes. In this case, it should remove an index without a filter with an index with a filter.`);
1630
+ }
1631
+ yield db.createOne(this.collectionName, {
1632
+ name: generateId(),
1633
+ uniqueField: 'hey there',
1634
+ slug: null,
1635
+ someField3: 'how are you?',
1636
+ });
1637
+ try {
1638
+ yield assert.doesThrowAsync(() => db.createOne(this.collectionName, {
1639
+ name: generateId(),
1640
+ uniqueField: 'hey there',
1641
+ slug: null,
1642
+ someField3: 'how are you?',
1643
+ }));
1644
+ }
1645
+ catch (_b) {
1646
+ assert.fail(`A record was created that should have been blocked by a unique index with a filter`);
1647
+ }
1648
+ });
1649
+ },
1599
1650
  assertSyncIndexesRemovesExtraIndexes(connect) {
1600
1651
  return __awaiter(this, void 0, void 0, function* () {
1601
1652
  const db = yield connectToDabatase(connect);
@@ -1604,12 +1655,12 @@ const databaseAssertUtil = {
1604
1655
  ['someField'],
1605
1656
  ['otherField', 'otherField2'],
1606
1657
  ]);
1607
- let indexes = yield this._getFilteredIndexes(db);
1658
+ let indexes = yield this._getIndexesWith_IdFilteredOut(db);
1608
1659
  assert.isLength(indexes, 3);
1609
1660
  yield db.syncIndexes(this.collectionName, [['name']]);
1610
- indexes = yield this._getFilteredIndexes(db);
1661
+ indexes = yield this._getIndexesWith_IdFilteredOut(db);
1611
1662
  assert.isLength(indexes, 1);
1612
- assert.isEqual(indexes[0][0], 'name');
1663
+ assert.isEqual(indexes[0].fields[0], 'name');
1613
1664
  yield this.shutdown(db);
1614
1665
  });
1615
1666
  },
@@ -1617,15 +1668,16 @@ const databaseAssertUtil = {
1617
1668
  return __awaiter(this, void 0, void 0, function* () {
1618
1669
  const db = yield connectToDabatase(connect);
1619
1670
  yield db.syncIndexes(this.collectionName, [['name']]);
1620
- let indexes = yield this._getFilteredIndexes(db);
1671
+ let indexes = yield this._getIndexesWith_IdFilteredOut(db);
1621
1672
  assert.isLength(indexes, 1);
1673
+ assert.isLength(indexes[0].fields, 1);
1622
1674
  yield db.syncIndexes(this.collectionName, [
1623
1675
  ['name'],
1624
1676
  ['someField'],
1625
1677
  ['otherField', 'otherField2'],
1626
1678
  ]);
1627
- indexes = yield this._getFilteredIndexes(db);
1628
- assert.isLength(indexes, 3);
1679
+ indexes = yield this._getIndexesWith_IdFilteredOut(db);
1680
+ assert.isLength(indexes, 3, 'There should be 3 indexes after the last sync. 1 would have been skipped, the other 2 should have been added');
1629
1681
  yield this.shutdown(db);
1630
1682
  });
1631
1683
  },
@@ -1639,7 +1691,7 @@ const databaseAssertUtil = {
1639
1691
  const err = yield assert.doesThrowAsync(() => db.dropIndex(this.collectionName, ['uniqueField', 'someOtherField']));
1640
1692
  errorAssert.assertError(err, 'INDEX_NOT_FOUND', {
1641
1693
  collectionName: this.collectionName,
1642
- missingIndex: ['uniqueField', 'someOtherField'],
1694
+ missingIndex: ['someOtherField', 'uniqueField'],
1643
1695
  });
1644
1696
  yield this.shutdown(db);
1645
1697
  });
@@ -1649,13 +1701,13 @@ const databaseAssertUtil = {
1649
1701
  const db = yield connectToDabatase(connect);
1650
1702
  yield db.createIndex(this.collectionName, ['someField', 'otherField']);
1651
1703
  yield db.dropIndex(this.collectionName, ['someField', 'otherField']);
1652
- let indexes = yield this._getFilteredIndexes(db);
1653
- assert.isLength(indexes, 0);
1704
+ let indexes = yield this._getIndexesWith_IdFilteredOut(db);
1705
+ assert.isLength(indexes, 0, `The one index I created should have been dropped`);
1654
1706
  yield db.createIndex(this.collectionName, ['someField', 'someField2']);
1655
1707
  yield db.createIndex(this.collectionName, ['someField', 'someField3']);
1656
1708
  yield db.dropIndex(this.collectionName, ['someField', 'someField3']);
1657
- indexes = yield this._getFilteredIndexes(db);
1658
- assert.isLength(indexes, 1);
1709
+ indexes = yield this._getIndexesWith_IdFilteredOut(db);
1710
+ assert.isLength(indexes, 1, `I created 2 compound indexes, then dropped one, and expected 1 to remain.`);
1659
1711
  yield this.shutdown(db);
1660
1712
  });
1661
1713
  },
@@ -1664,12 +1716,12 @@ const databaseAssertUtil = {
1664
1716
  const db = yield connectToDabatase(connect);
1665
1717
  yield db.createIndex(this.collectionName, ['someField']);
1666
1718
  yield db.dropIndex(this.collectionName, ['someField']);
1667
- let indexes = yield this._getFilteredIndexes(db);
1719
+ let indexes = yield this._getIndexesWith_IdFilteredOut(db);
1668
1720
  assert.isLength(indexes, 0);
1669
1721
  yield db.createIndex(this.collectionName, ['someField2']);
1670
1722
  yield db.createIndex(this.collectionName, ['someField3']);
1671
1723
  yield db.dropIndex(this.collectionName, ['someField3']);
1672
- indexes = yield this._getFilteredIndexes(db);
1724
+ indexes = yield this._getIndexesWith_IdFilteredOut(db);
1673
1725
  assert.isLength(indexes, 1);
1674
1726
  yield this.shutdown(db);
1675
1727
  });
@@ -1698,7 +1750,7 @@ const databaseAssertUtil = {
1698
1750
  return __awaiter(this, void 0, void 0, function* () {
1699
1751
  const db = yield connectToDabatase(connect);
1700
1752
  yield db.createIndex(this.collectionName, ['name']);
1701
- let indexes = yield this._getFilteredIndexes(db);
1753
+ let indexes = yield this._getIndexesWith_IdFilteredOut(db);
1702
1754
  assert.isLength(indexes, 1);
1703
1755
  const err = yield assert.doesThrowAsync(() => db.createIndex(this.collectionName, ['name']));
1704
1756
  errorAssert.assertError(err, 'INDEX_EXISTS');
@@ -1709,23 +1761,23 @@ const databaseAssertUtil = {
1709
1761
  return __awaiter(this, void 0, void 0, function* () {
1710
1762
  const db = yield connectToDabatase(connect);
1711
1763
  yield db.createIndex(this.collectionName, ['uniqueField']);
1712
- let indexes = yield this._getFilteredIndexes(db);
1764
+ let indexes = yield this._getIndexesWith_IdFilteredOut(db);
1713
1765
  assert.isArray(indexes, 'getIndexes() should return an array!');
1714
1766
  assert.isLength(indexes, 1, 'getIndexes() should return the one index that was created!');
1715
- assert.isLength(indexes[0], 1, 'getIndexes() should return an array of arrays! It should be returing the first index I created!');
1716
- assert.isEqual(indexes[0][0].toLowerCase(), 'uniqueField'.toLowerCase());
1767
+ assert.isLength(indexes[0].fields, 1, 'getIndexes() should return an array of IndexWithFilter! It should be returing the first index I created with the first field!');
1768
+ assert.isEqual(indexes[0].fields[0].toLowerCase(), 'uniqueField'.toLowerCase());
1717
1769
  yield db.createIndex(this.collectionName, ['uniqueField2']);
1718
- indexes = yield this._getFilteredIndexes(db);
1770
+ indexes = yield this._getIndexesWith_IdFilteredOut(db);
1719
1771
  assert.isLength(indexes, 2);
1720
- assert.isEqual(indexes[1][0].toLowerCase(), 'uniqueField2'.toLowerCase());
1772
+ assert.isEqual(indexes[1].fields[0].toLowerCase(), 'uniqueField2'.toLowerCase());
1721
1773
  yield db.createIndex(this.collectionName, [
1722
1774
  'uniqueField3',
1723
1775
  'uniqueField4',
1724
1776
  ]);
1725
- indexes = yield this._getFilteredIndexes(db);
1777
+ indexes = yield this._getIndexesWith_IdFilteredOut(db);
1726
1778
  assert.isLength(indexes, 3);
1727
- assert.isEqual(indexes[2][0].toLowerCase(), 'uniqueField3'.toLowerCase());
1728
- assert.isEqual(indexes[2][1].toLowerCase(), 'uniqueField4'.toLowerCase());
1779
+ assert.isEqual(indexes[2].fields[0].toLowerCase(), 'uniqueField3'.toLowerCase());
1780
+ assert.isEqual(indexes[2].fields[1].toLowerCase(), 'uniqueField4'.toLowerCase());
1729
1781
  yield this.shutdown(db);
1730
1782
  });
1731
1783
  },
@@ -1886,9 +1938,9 @@ const databaseAssertUtil = {
1886
1938
  return __awaiter(this, void 0, void 0, function* () {
1887
1939
  const db = yield connectToDabatase(connect);
1888
1940
  yield db.createIndex(this.collectionName, fields);
1889
- const indexes = yield this._getFilteredIndexes(db);
1941
+ const indexes = yield this._getIndexesWith_IdFilteredOut(db);
1890
1942
  assert.isLength(indexes, 1, `getIndexes() should return the index it created. I expected 1 but got ${indexes.length}. Also, make sure you clear the indexes when resetting the database!`);
1891
- assert.isEqualDeep(indexes[0].map((i) => i.toLowerCase()), fields.map((f) => f.toLowerCase()));
1943
+ assert.isEqualDeep(indexes[0].fields.map((i) => i.toLowerCase()), fields.map((f) => f.toLowerCase()));
1892
1944
  yield this.shutdown(db);
1893
1945
  });
1894
1946
  },
@@ -1903,11 +1955,11 @@ function assertCantCreateUniqueIndexTwice(db, collectionName, fields, expectedTo
1903
1955
  return __awaiter(this, void 0, void 0, function* () {
1904
1956
  yield db.createUniqueIndex(collectionName, fields);
1905
1957
  let indexes = yield db.getUniqueIndexes(collectionName);
1906
- assert.isLength(indexes, expectedTotalUniqueIndexes, 'getUniqueIndexes() should return total unique indexs');
1907
- const err = yield assert.doesThrowAsync(() => db.createUniqueIndex(collectionName, ['uniqueField']), undefined, 'createUniqueIndex() should throw a DataStoreError({code: "INDEX_EXISTS"}) error.');
1958
+ assert.isLength(indexes, expectedTotalUniqueIndexes, 'getUniqueIndexes() should return all unique indexes');
1959
+ const err = yield assert.doesThrowAsync(() => db.createUniqueIndex(collectionName, fields), undefined, 'createUniqueIndex() should throw a DataStoreError({code: "INDEX_EXISTS"}) error.');
1908
1960
  errorAssert.assertError(err, 'INDEX_EXISTS', {
1909
1961
  collectionName,
1910
- index: ['uniqueField'],
1962
+ index: fields,
1911
1963
  });
1912
1964
  });
1913
1965
  }
@@ -2,11 +2,11 @@ import { Log } from '@sprucelabs/spruce-skill-utils';
2
2
  import { QueryOptions } from './query.types';
3
3
  export interface Database {
4
4
  [x: string]: any;
5
- syncUniqueIndexes(collectionName: string, indexes: UniqueIndex[]): Promise<void>;
5
+ syncUniqueIndexes(collectionName: string, indexes: Index[]): Promise<void>;
6
6
  syncIndexes(collectionName: string, indexes: Index[]): Promise<void>;
7
- dropIndex(collectionName: string, fields: UniqueIndex): Promise<void>;
8
- getUniqueIndexes(collectionName: string): Promise<UniqueIndex[]>;
9
- getIndexes(collectionName: string): Promise<Index[] | UniqueIndex[]>;
7
+ dropIndex(collectionName: string, index: Index): Promise<void>;
8
+ getUniqueIndexes(collectionName: string): Promise<IndexWithFilter[]>;
9
+ getIndexes(collectionName: string): Promise<IndexWithFilter[]>;
10
10
  isConnected(): boolean;
11
11
  generateId(): string;
12
12
  connect(): Promise<void>;
@@ -24,8 +24,8 @@ export interface Database {
24
24
  delete(collection: string, query: Record<string, any>): Promise<number>;
25
25
  deleteOne(collection: string, query: Record<string, any>): Promise<number>;
26
26
  count(collection: string, query?: Record<string, any>): Promise<number>;
27
- createUniqueIndex(collection: string, fields: UniqueIndex): Promise<void>;
28
- createIndex(collection: string, fields: Index): Promise<void>;
27
+ createUniqueIndex(collection: string, index: Index): Promise<void>;
28
+ createIndex(collection: string, index: Index): Promise<void>;
29
29
  query<T>(query: string, params?: any[]): Promise<T[]>;
30
30
  }
31
31
  export interface DatabaseOptions {
@@ -40,10 +40,9 @@ export type TestConnect = (connectionString?: string, dbName?: string) => Promis
40
40
  }>;
41
41
  export interface IndexWithFilter {
42
42
  fields: string[];
43
- filter: Record<string, any>;
43
+ filter?: Record<string, any>;
44
44
  }
45
- export type UniqueIndex = string[] | IndexWithFilter;
46
- export type Index = string[];
45
+ export type Index = string[] | IndexWithFilter;
47
46
  export interface CreateOptions extends DatabaseInternalOptions {
48
47
  }
49
48
  export interface DatabaseInternalOptions {
package/build/index.d.ts CHANGED
@@ -21,7 +21,7 @@ export * from './cursors/CursorPager';
21
21
  export { default as CursorPagerFaker } from './cursors/CursorPagerFaker';
22
22
  export * from './cursors/CursorPager';
23
23
  export { default as DatabaseFieldMapperPlugin } from './plugins/DatabaseFieldMapperPlugin';
24
- export { default as normalizeIndex } from './databases/normalizeIndex';
24
+ export * from './databases/database.utilities';
25
25
  /**
26
26
  * @deprecated databaseAssertUtil -> databaseAssert
27
27
  */
package/build/index.js CHANGED
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.BatchArrayCursor = exports.BatchCursorImpl = exports.storePluginAssert = exports.databaseAssert = exports.databaseAssertUtil = exports.normalizeIndex = exports.DatabaseFieldMapperPlugin = exports.CursorPagerFaker = exports.CursorPager = exports.generateId = exports.DataStoresError = exports.mongoUtil = exports.NeDbDatabase = exports.MongoDatabase = exports.StoreLoader = exports.DatabaseFactory = exports.StoreFactory = exports.AbstractStore = exports.DatabaseFixture = exports.AbstractDatabaseTest = void 0;
20
+ exports.BatchArrayCursor = exports.BatchCursorImpl = exports.storePluginAssert = exports.databaseAssert = exports.databaseAssertUtil = exports.DatabaseFieldMapperPlugin = exports.CursorPagerFaker = exports.CursorPager = exports.generateId = exports.DataStoresError = exports.mongoUtil = exports.NeDbDatabase = exports.MongoDatabase = exports.StoreLoader = exports.DatabaseFactory = exports.StoreFactory = exports.AbstractStore = exports.DatabaseFixture = exports.AbstractDatabaseTest = void 0;
21
21
  var AbstractDatabaseTest_1 = require("./tests/AbstractDatabaseTest");
22
22
  Object.defineProperty(exports, "AbstractDatabaseTest", { enumerable: true, get: function () { return __importDefault(AbstractDatabaseTest_1).default; } });
23
23
  var DatabaseFixture_1 = require("./fixtures/DatabaseFixture");
@@ -55,8 +55,7 @@ Object.defineProperty(exports, "CursorPagerFaker", { enumerable: true, get: func
55
55
  __exportStar(require("./cursors/CursorPager"), exports);
56
56
  var DatabaseFieldMapperPlugin_1 = require("./plugins/DatabaseFieldMapperPlugin");
57
57
  Object.defineProperty(exports, "DatabaseFieldMapperPlugin", { enumerable: true, get: function () { return __importDefault(DatabaseFieldMapperPlugin_1).default; } });
58
- var normalizeIndex_1 = require("./databases/normalizeIndex");
59
- Object.defineProperty(exports, "normalizeIndex", { enumerable: true, get: function () { return __importDefault(normalizeIndex_1).default; } });
58
+ __exportStar(require("./databases/database.utilities"), exports);
60
59
  /**
61
60
  * @deprecated databaseAssertUtil -> databaseAssert
62
61
  */
@@ -1,10 +1,10 @@
1
- import { Database, Index, TestConnect, UniqueIndex } from '../types/database.types';
1
+ import { Database, IndexWithFilter, TestConnect } from '../types/database.types';
2
2
  import { DataStore } from '../types/stores.types';
3
3
  declare const databaseAssertUtil: {
4
4
  collectionName: string;
5
5
  runSuite(connect: TestConnect, tests?: string[]): Promise<void>;
6
- _getFilteredIndexes(db: Database): Promise<string[][]>;
7
- _filterIdIndex(allIndexes: UniqueIndex[] | Index[]): UniqueIndex[] | Index[];
6
+ _getIndexesWith_IdFilteredOut(db: Database): Promise<IndexWithFilter[]>;
7
+ _filterOut_Id(allIndexes: IndexWithFilter[]): IndexWithFilter[];
8
8
  _assertUpdateUpdatedRightNumberOfRecords(db: Database, search: Record<string, any>, updates: Record<string, any>, expectedUpdateCount: number): Promise<void>;
9
9
  generateIdDifferentEachTime(connect: TestConnect): Promise<void>;
10
10
  assertCanSortDesc(connect: TestConnect): Promise<void>;
@@ -64,6 +64,7 @@ declare const databaseAssertUtil: {
64
64
  assertCanSaveAndGetNullAndUndefined(connect: TestConnect): Promise<void>;
65
65
  assertSyncIndexesDoesNotRemoveExisting(connect: TestConnect): Promise<void>;
66
66
  assertCanSyncUniqueIndexesWithFilterExpression(connect: TestConnect): Promise<void>;
67
+ assertCanSyncIndexesWithoutPartialThenAgainWithProperlyUpdates(connect: TestConnect): Promise<void>;
67
68
  assertSyncIndexesRemovesExtraIndexes(connect: TestConnect): Promise<void>;
68
69
  assertSyncIndexesSkipsExisting(connect: TestConnect): Promise<void>;
69
70
  assertCantDropCompoundIndexThatDoesNotExist(connect: TestConnect): Promise<void>;