@sprucelabs/data-stores 28.1.349 → 28.3.0
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/build/databases/MongoDatabase.d.ts +2 -4
- package/build/databases/MongoDatabase.js +10 -10
- package/build/databases/database.utilities.js +9 -1
- package/build/esm/databases/MongoDatabase.d.ts +2 -4
- package/build/esm/databases/MongoDatabase.js +10 -10
- package/build/esm/databases/database.utilities.js +9 -1
- package/build/esm/tests/databaseAssertUtil.d.ts +5 -3
- package/build/esm/tests/databaseAssertUtil.js +19 -6
- package/build/esm/types/database.types.d.ts +1 -0
- package/build/tests/databaseAssertUtil.d.ts +5 -3
- package/build/tests/databaseAssertUtil.js +18 -5
- package/build/types/database.types.d.ts +1 -0
- package/package.json +1 -1
@@ -28,10 +28,8 @@ export default class MongoDatabase implements Database {
|
|
28
28
|
private listIndexes;
|
29
29
|
dropIndex(collection: string, index: Index): Promise<void>;
|
30
30
|
getUniqueIndexes(collection: string): Promise<IndexWithFilter[]>;
|
31
|
-
getIndexes(collection: string, shouldIncludeUnique?: boolean): Promise<IndexWithFilter[]
|
32
|
-
|
33
|
-
filter: any;
|
34
|
-
}[]>;
|
31
|
+
getIndexes(collection: string, shouldIncludeUnique?: boolean): Promise<IndexWithFilter[]>;
|
32
|
+
private mongoIndexToIndexWithFilter;
|
35
33
|
createIndex(collection: string, index: Index): Promise<void>;
|
36
34
|
private assertIndexDoesNotExist;
|
37
35
|
private doesInclude;
|
@@ -276,18 +276,12 @@ class MongoDatabase {
|
|
276
276
|
try {
|
277
277
|
const indexes = await this.listIndexes(collection);
|
278
278
|
if (shouldIncludeUnique) {
|
279
|
-
return indexes.map((index) => (
|
280
|
-
fields: Object.keys(index.key),
|
281
|
-
filter: index.partialFilterExpression,
|
282
|
-
}));
|
279
|
+
return indexes.map((index) => this.mongoIndexToIndexWithFilter(index));
|
283
280
|
}
|
284
281
|
const nonUniqueIndexes = [];
|
285
282
|
for (const index of indexes) {
|
286
283
|
if (!index.unique) {
|
287
|
-
nonUniqueIndexes.push(
|
288
|
-
fields: Object.keys(index.key),
|
289
|
-
filter: undefined,
|
290
|
-
});
|
284
|
+
nonUniqueIndexes.push(this.mongoIndexToIndexWithFilter(index));
|
291
285
|
}
|
292
286
|
}
|
293
287
|
return nonUniqueIndexes;
|
@@ -296,6 +290,13 @@ class MongoDatabase {
|
|
296
290
|
return [];
|
297
291
|
}
|
298
292
|
}
|
293
|
+
mongoIndexToIndexWithFilter(index) {
|
294
|
+
return {
|
295
|
+
fields: Object.keys(index.key),
|
296
|
+
filter: index.partialFilterExpression,
|
297
|
+
name: index.name,
|
298
|
+
};
|
299
|
+
}
|
299
300
|
async createIndex(collection, index) {
|
300
301
|
const currentIndexes = await this.getIndexes(collection);
|
301
302
|
this.assertIndexDoesNotExist(currentIndexes, index, collection);
|
@@ -394,8 +395,7 @@ class MongoDatabase {
|
|
394
395
|
return (0, database_utilities_1.generateIndexName)(this.normalizeIndex(indexWithFilter));
|
395
396
|
}
|
396
397
|
normalizeIndex(index) {
|
397
|
-
|
398
|
-
return { fields, filter };
|
398
|
+
return (0, database_utilities_1.normalizeIndex)(index);
|
399
399
|
}
|
400
400
|
async syncUniqueIndexes(collectionName, indexes) {
|
401
401
|
await this._syncIndexes(collectionName, indexes, 'createUniqueIndex', true);
|
@@ -23,6 +23,9 @@ function areIndexesEqual(left, right) {
|
|
23
23
|
return name1 === name2;
|
24
24
|
}
|
25
25
|
function generateIndexName(indexWithFilter) {
|
26
|
+
if (indexWithFilter.name) {
|
27
|
+
return indexWithFilter.name;
|
28
|
+
}
|
26
29
|
let name = indexWithFilter.fields.join('_');
|
27
30
|
if (indexWithFilter.filter) {
|
28
31
|
name += '_filtered';
|
@@ -30,10 +33,15 @@ function generateIndexName(indexWithFilter) {
|
|
30
33
|
return name;
|
31
34
|
}
|
32
35
|
function normalizeIndex(index) {
|
36
|
+
var _a;
|
33
37
|
const fields = Array.isArray(index) ? index : index.fields;
|
34
38
|
const filter = Array.isArray(index) ? undefined : index.filter;
|
35
39
|
fields.sort();
|
36
|
-
return {
|
40
|
+
return {
|
41
|
+
fields,
|
42
|
+
filter,
|
43
|
+
name: (_a = index.name) !== null && _a !== void 0 ? _a : undefined,
|
44
|
+
};
|
37
45
|
}
|
38
46
|
function pluckMissingIndexes(left, right) {
|
39
47
|
return (0, differenceWith_1.default)(left, right, areIndexesEqual);
|
@@ -28,10 +28,8 @@ export default class MongoDatabase implements Database {
|
|
28
28
|
private listIndexes;
|
29
29
|
dropIndex(collection: string, index: Index): Promise<void>;
|
30
30
|
getUniqueIndexes(collection: string): Promise<IndexWithFilter[]>;
|
31
|
-
getIndexes(collection: string, shouldIncludeUnique?: boolean): Promise<IndexWithFilter[]
|
32
|
-
|
33
|
-
filter: any;
|
34
|
-
}[]>;
|
31
|
+
getIndexes(collection: string, shouldIncludeUnique?: boolean): Promise<IndexWithFilter[]>;
|
32
|
+
private mongoIndexToIndexWithFilter;
|
35
33
|
createIndex(collection: string, index: Index): Promise<void>;
|
36
34
|
private assertIndexDoesNotExist;
|
37
35
|
private doesInclude;
|
@@ -306,18 +306,12 @@ export default class MongoDatabase {
|
|
306
306
|
try {
|
307
307
|
const indexes = yield this.listIndexes(collection);
|
308
308
|
if (shouldIncludeUnique) {
|
309
|
-
return indexes.map((index) => (
|
310
|
-
fields: Object.keys(index.key),
|
311
|
-
filter: index.partialFilterExpression,
|
312
|
-
}));
|
309
|
+
return indexes.map((index) => this.mongoIndexToIndexWithFilter(index));
|
313
310
|
}
|
314
311
|
const nonUniqueIndexes = [];
|
315
312
|
for (const index of indexes) {
|
316
313
|
if (!index.unique) {
|
317
|
-
nonUniqueIndexes.push(
|
318
|
-
fields: Object.keys(index.key),
|
319
|
-
filter: undefined,
|
320
|
-
});
|
314
|
+
nonUniqueIndexes.push(this.mongoIndexToIndexWithFilter(index));
|
321
315
|
}
|
322
316
|
}
|
323
317
|
return nonUniqueIndexes;
|
@@ -327,6 +321,13 @@ export default class MongoDatabase {
|
|
327
321
|
}
|
328
322
|
});
|
329
323
|
}
|
324
|
+
mongoIndexToIndexWithFilter(index) {
|
325
|
+
return {
|
326
|
+
fields: Object.keys(index.key),
|
327
|
+
filter: index.partialFilterExpression,
|
328
|
+
name: index.name,
|
329
|
+
};
|
330
|
+
}
|
330
331
|
createIndex(collection, index) {
|
331
332
|
return __awaiter(this, void 0, void 0, function* () {
|
332
333
|
const currentIndexes = yield this.getIndexes(collection);
|
@@ -433,8 +434,7 @@ export default class MongoDatabase {
|
|
433
434
|
return generateIndexName(this.normalizeIndex(indexWithFilter));
|
434
435
|
}
|
435
436
|
normalizeIndex(index) {
|
436
|
-
|
437
|
-
return { fields, filter };
|
437
|
+
return normalizeIndex(index);
|
438
438
|
}
|
439
439
|
syncUniqueIndexes(collectionName, indexes) {
|
440
440
|
return __awaiter(this, void 0, void 0, function* () {
|
@@ -13,6 +13,9 @@ export function areIndexesEqual(left, right) {
|
|
13
13
|
return name1 === name2;
|
14
14
|
}
|
15
15
|
export function generateIndexName(indexWithFilter) {
|
16
|
+
if (indexWithFilter.name) {
|
17
|
+
return indexWithFilter.name;
|
18
|
+
}
|
16
19
|
let name = indexWithFilter.fields.join('_');
|
17
20
|
if (indexWithFilter.filter) {
|
18
21
|
name += '_filtered';
|
@@ -20,10 +23,15 @@ export function generateIndexName(indexWithFilter) {
|
|
20
23
|
return name;
|
21
24
|
}
|
22
25
|
export function normalizeIndex(index) {
|
26
|
+
var _a;
|
23
27
|
const fields = Array.isArray(index) ? index : index.fields;
|
24
28
|
const filter = Array.isArray(index) ? undefined : index.filter;
|
25
29
|
fields.sort();
|
26
|
-
return {
|
30
|
+
return {
|
31
|
+
fields,
|
32
|
+
filter,
|
33
|
+
name: (_a = index.name) !== null && _a !== void 0 ? _a : undefined,
|
34
|
+
};
|
27
35
|
}
|
28
36
|
export function pluckMissingIndexes(left, right) {
|
29
37
|
return differenceWith(left, right, areIndexesEqual);
|
@@ -1,14 +1,16 @@
|
|
1
1
|
import { Database, IndexWithFilter, TestConnect } from '../types/database.types';
|
2
2
|
import { DataStore } from '../types/stores.types';
|
3
|
-
declare const methods: readonly ["assertThrowsWithInvalidConnectionString", "assertThrowsWhenCantConnect", "assertThrowsWithBadDatabaseName", "
|
4
|
-
|
3
|
+
declare const methods: readonly ["assertThrowsWithInvalidConnectionString", "assertThrowsWhenCantConnect", "assertThrowsWithBadDatabaseName", "assertKnowsIfConnectionClosed", "assertCanSortDesc", "assertCanSortAsc", "assertCanSortById", "assertCanQueryWithOr", "assertGeneratesIdDifferentEachTime", "assertInsertingGeneratesId", "assertCanCreateMany", "assertCanCreateWithObjectField", "assertCanCountOnId", "assertCanCount", "assertThrowsWhenUpdatingRecordNotFound", "assertCanUpdate", "assertCanUpdateMany", "assertCanPushOntoArrayValue", "assertCanUpdateWithObjectField", "assertCanUpdateFieldInObjectFieldWithTargettedWhere", "assertCanSaveAndGetNullAndUndefined", "assertCanUpsertOne", "assertCanUpsertNull", "assertCanPushToArrayOnUpsert", "assertCanSyncUniqueIndexesWithFilterExpression", "assertEmptyDatabaseReturnsEmptyArray", "assertFindOneOnEmptyDatabaseReturnsNull", "assertCanLimitResults", "assertCanLimitResultsToZero", "assertCanFindWithBooleanField", "assertCanQueryByGtLtGteLteNe", "assertCanQueryPathWithDotSyntax", "assertCanReturnOnlySelectFields", "assertCanSearchByRegex", "assertCanFindWithNe", "assertCanFindWithIn", "assertCanDeleteRecord", "assertCanDeleteOne", "assertHasNoUniqueIndexToStart", "assertCanCreateUniqueIndex", "assertCanCreateMultiFieldUniqueIndex", "assertCantCreateUniqueIndexTwice", "assertCanDropUniqueIndex", "assertCanDropCompoundUniqueIndex", "assertCantDropUniqueIndexThatDoesntExist", "assertCantDropIndexWhenNoIndexExists", "assertCantDropCompoundUniqueIndexThatDoesntExist", "assertSyncingUniqueIndexsAddsMissingIndexes", "assertSyncingUniqueIndexsSkipsExistingIndexs", "assertSyncingUniqueIndexesRemovesExtraIndexes", "assertSyncingUniqueIndexesIsRaceProof", "assertSyncingIndexesDoesNotAddAndRemove", "assertUniqueIndexBlocksDuplicates", "assertDuplicateKeyThrowsOnInsert", "assertSettingUniqueIndexViolationThrowsSpruceError", "assertCanCreateUniqueIndexOnNestedField", "assertUpsertWithUniqueIndex", "assertNestedFieldIndexUpdates", "assertHasNoIndexToStart", "assertCanCreateIndex", "assertCantCreateSameIndexTwice", "assertCanCreateMultiFieldIndex", "assertCanDropIndex", "assertCanDropCompoundIndex", "assertCantDropCompoundIndexThatDoesNotExist", "assertSyncIndexesSkipsExisting", "assertSyncIndexesRemovesExtraIndexes", "assertSyncIndexesHandlesRaceConditions", "assertSyncIndexesDoesNotRemoveExisting", "assertDuplicateFieldsWithMultipleUniqueIndexesWorkAsExpected", "assertCanSyncIndexesWithoutPartialThenAgainWithProperlyUpdates"];
|
4
|
+
type OriginalMethods = (typeof methods)[number];
|
5
|
+
type BangMethods = `!${OriginalMethods}`;
|
6
|
+
export type DatabaseAssertionName = OriginalMethods | BangMethods;
|
5
7
|
declare const databaseAssertUtil: {
|
6
8
|
collectionName: string;
|
7
9
|
runSuite(connect: TestConnect, tests?: DatabaseAssertionName[]): Promise<void>;
|
8
10
|
_getIndexesWith_IdFilteredOut(db: Database): Promise<IndexWithFilter[]>;
|
9
11
|
_filterOut_Id(allIndexes: IndexWithFilter[]): IndexWithFilter[];
|
10
12
|
_assertUpdateUpdatedRightNumberOfRecords(db: Database, search: Record<string, any>, updates: Record<string, any>, expectedUpdateCount: number): Promise<void>;
|
11
|
-
|
13
|
+
assertGeneratesIdDifferentEachTime(connect: TestConnect): Promise<void>;
|
12
14
|
assertCanSortDesc(connect: TestConnect): Promise<void>;
|
13
15
|
assertCanSortAsc(connect: TestConnect): Promise<void>;
|
14
16
|
assertInsertingGeneratesId(connect: TestConnect): Promise<void>;
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
8
|
});
|
9
9
|
};
|
10
|
-
import { assertOptions } from '@sprucelabs/schema';
|
10
|
+
import { assertOptions, SchemaError } from '@sprucelabs/schema';
|
11
11
|
import { assert } from '@sprucelabs/test-utils';
|
12
12
|
import { errorAssert } from '@sprucelabs/test-utils';
|
13
13
|
import generateId from '../utilities/generateId.js';
|
@@ -17,17 +17,14 @@ const methods = [
|
|
17
17
|
'assertThrowsWhenCantConnect',
|
18
18
|
'assertThrowsWithBadDatabaseName',
|
19
19
|
//inserting
|
20
|
-
'assertEmptyDatabaseReturnsEmptyArray',
|
21
20
|
'assertKnowsIfConnectionClosed',
|
22
|
-
'assertFindOneOnEmptyDatabaseReturnsNull',
|
23
21
|
'assertCanSortDesc',
|
24
22
|
'assertCanSortAsc',
|
25
23
|
'assertCanSortById',
|
26
24
|
'assertCanQueryWithOr',
|
27
|
-
'
|
25
|
+
'assertGeneratesIdDifferentEachTime',
|
28
26
|
'assertInsertingGeneratesId',
|
29
27
|
'assertCanCreateMany',
|
30
|
-
'assertCanLimitResults',
|
31
28
|
'assertCanCreateWithObjectField',
|
32
29
|
//counting
|
33
30
|
'assertCanCountOnId',
|
@@ -103,6 +100,22 @@ const databaseAssertUtil = {
|
|
103
100
|
const db = yield connectToDabatase(connect);
|
104
101
|
yield db.dropDatabase();
|
105
102
|
yield this.shutdown(db);
|
103
|
+
const hasIgnore = tests === null || tests === void 0 ? void 0 : tests.find((t) => t.startsWith('!'));
|
104
|
+
if (hasIgnore && tests) {
|
105
|
+
for (const method of tests) {
|
106
|
+
if (!method.startsWith('!')) {
|
107
|
+
throw new SchemaError({
|
108
|
+
code: 'INVALID_PARAMETERS',
|
109
|
+
parameters: ['tests'],
|
110
|
+
});
|
111
|
+
}
|
112
|
+
}
|
113
|
+
const doesMatch = (m) => {
|
114
|
+
return !!tests.find((t) => t.substring(1) === m);
|
115
|
+
};
|
116
|
+
const filtered = methods.filter((m) => !doesMatch(m));
|
117
|
+
tests = filtered;
|
118
|
+
}
|
106
119
|
const toRun = tests !== null && tests !== void 0 ? tests : methods;
|
107
120
|
for (const method of toRun) {
|
108
121
|
try {
|
@@ -134,7 +147,7 @@ const databaseAssertUtil = {
|
|
134
147
|
assert.isEqual(count, expectedUpdateCount);
|
135
148
|
});
|
136
149
|
},
|
137
|
-
|
150
|
+
assertGeneratesIdDifferentEachTime(connect) {
|
138
151
|
return __awaiter(this, void 0, void 0, function* () {
|
139
152
|
const db = yield connectToDabatase(connect);
|
140
153
|
const id1 = db.generateId();
|
@@ -41,6 +41,7 @@ export type TestConnect = (connectionString?: string, dbName?: string) => Promis
|
|
41
41
|
export interface IndexWithFilter {
|
42
42
|
fields: string[];
|
43
43
|
filter?: Record<string, any>;
|
44
|
+
name?: string;
|
44
45
|
}
|
45
46
|
export type Index = string[] | IndexWithFilter;
|
46
47
|
export interface CreateOptions extends DatabaseInternalOptions {
|
@@ -1,14 +1,16 @@
|
|
1
1
|
import { Database, IndexWithFilter, TestConnect } from '../types/database.types';
|
2
2
|
import { DataStore } from '../types/stores.types';
|
3
|
-
declare const methods: readonly ["assertThrowsWithInvalidConnectionString", "assertThrowsWhenCantConnect", "assertThrowsWithBadDatabaseName", "
|
4
|
-
|
3
|
+
declare const methods: readonly ["assertThrowsWithInvalidConnectionString", "assertThrowsWhenCantConnect", "assertThrowsWithBadDatabaseName", "assertKnowsIfConnectionClosed", "assertCanSortDesc", "assertCanSortAsc", "assertCanSortById", "assertCanQueryWithOr", "assertGeneratesIdDifferentEachTime", "assertInsertingGeneratesId", "assertCanCreateMany", "assertCanCreateWithObjectField", "assertCanCountOnId", "assertCanCount", "assertThrowsWhenUpdatingRecordNotFound", "assertCanUpdate", "assertCanUpdateMany", "assertCanPushOntoArrayValue", "assertCanUpdateWithObjectField", "assertCanUpdateFieldInObjectFieldWithTargettedWhere", "assertCanSaveAndGetNullAndUndefined", "assertCanUpsertOne", "assertCanUpsertNull", "assertCanPushToArrayOnUpsert", "assertCanSyncUniqueIndexesWithFilterExpression", "assertEmptyDatabaseReturnsEmptyArray", "assertFindOneOnEmptyDatabaseReturnsNull", "assertCanLimitResults", "assertCanLimitResultsToZero", "assertCanFindWithBooleanField", "assertCanQueryByGtLtGteLteNe", "assertCanQueryPathWithDotSyntax", "assertCanReturnOnlySelectFields", "assertCanSearchByRegex", "assertCanFindWithNe", "assertCanFindWithIn", "assertCanDeleteRecord", "assertCanDeleteOne", "assertHasNoUniqueIndexToStart", "assertCanCreateUniqueIndex", "assertCanCreateMultiFieldUniqueIndex", "assertCantCreateUniqueIndexTwice", "assertCanDropUniqueIndex", "assertCanDropCompoundUniqueIndex", "assertCantDropUniqueIndexThatDoesntExist", "assertCantDropIndexWhenNoIndexExists", "assertCantDropCompoundUniqueIndexThatDoesntExist", "assertSyncingUniqueIndexsAddsMissingIndexes", "assertSyncingUniqueIndexsSkipsExistingIndexs", "assertSyncingUniqueIndexesRemovesExtraIndexes", "assertSyncingUniqueIndexesIsRaceProof", "assertSyncingIndexesDoesNotAddAndRemove", "assertUniqueIndexBlocksDuplicates", "assertDuplicateKeyThrowsOnInsert", "assertSettingUniqueIndexViolationThrowsSpruceError", "assertCanCreateUniqueIndexOnNestedField", "assertUpsertWithUniqueIndex", "assertNestedFieldIndexUpdates", "assertHasNoIndexToStart", "assertCanCreateIndex", "assertCantCreateSameIndexTwice", "assertCanCreateMultiFieldIndex", "assertCanDropIndex", "assertCanDropCompoundIndex", "assertCantDropCompoundIndexThatDoesNotExist", "assertSyncIndexesSkipsExisting", "assertSyncIndexesRemovesExtraIndexes", "assertSyncIndexesHandlesRaceConditions", "assertSyncIndexesDoesNotRemoveExisting", "assertDuplicateFieldsWithMultipleUniqueIndexesWorkAsExpected", "assertCanSyncIndexesWithoutPartialThenAgainWithProperlyUpdates"];
|
4
|
+
type OriginalMethods = (typeof methods)[number];
|
5
|
+
type BangMethods = `!${OriginalMethods}`;
|
6
|
+
export type DatabaseAssertionName = OriginalMethods | BangMethods;
|
5
7
|
declare const databaseAssertUtil: {
|
6
8
|
collectionName: string;
|
7
9
|
runSuite(connect: TestConnect, tests?: DatabaseAssertionName[]): Promise<void>;
|
8
10
|
_getIndexesWith_IdFilteredOut(db: Database): Promise<IndexWithFilter[]>;
|
9
11
|
_filterOut_Id(allIndexes: IndexWithFilter[]): IndexWithFilter[];
|
10
12
|
_assertUpdateUpdatedRightNumberOfRecords(db: Database, search: Record<string, any>, updates: Record<string, any>, expectedUpdateCount: number): Promise<void>;
|
11
|
-
|
13
|
+
assertGeneratesIdDifferentEachTime(connect: TestConnect): Promise<void>;
|
12
14
|
assertCanSortDesc(connect: TestConnect): Promise<void>;
|
13
15
|
assertCanSortAsc(connect: TestConnect): Promise<void>;
|
14
16
|
assertInsertingGeneratesId(connect: TestConnect): Promise<void>;
|
@@ -13,17 +13,14 @@ const methods = [
|
|
13
13
|
'assertThrowsWhenCantConnect',
|
14
14
|
'assertThrowsWithBadDatabaseName',
|
15
15
|
//inserting
|
16
|
-
'assertEmptyDatabaseReturnsEmptyArray',
|
17
16
|
'assertKnowsIfConnectionClosed',
|
18
|
-
'assertFindOneOnEmptyDatabaseReturnsNull',
|
19
17
|
'assertCanSortDesc',
|
20
18
|
'assertCanSortAsc',
|
21
19
|
'assertCanSortById',
|
22
20
|
'assertCanQueryWithOr',
|
23
|
-
'
|
21
|
+
'assertGeneratesIdDifferentEachTime',
|
24
22
|
'assertInsertingGeneratesId',
|
25
23
|
'assertCanCreateMany',
|
26
|
-
'assertCanLimitResults',
|
27
24
|
'assertCanCreateWithObjectField',
|
28
25
|
//counting
|
29
26
|
'assertCanCountOnId',
|
@@ -98,6 +95,22 @@ const databaseAssertUtil = {
|
|
98
95
|
const db = await connectToDabatase(connect);
|
99
96
|
await db.dropDatabase();
|
100
97
|
await this.shutdown(db);
|
98
|
+
const hasIgnore = tests === null || tests === void 0 ? void 0 : tests.find((t) => t.startsWith('!'));
|
99
|
+
if (hasIgnore && tests) {
|
100
|
+
for (const method of tests) {
|
101
|
+
if (!method.startsWith('!')) {
|
102
|
+
throw new schema_1.SchemaError({
|
103
|
+
code: 'INVALID_PARAMETERS',
|
104
|
+
parameters: ['tests'],
|
105
|
+
});
|
106
|
+
}
|
107
|
+
}
|
108
|
+
const doesMatch = (m) => {
|
109
|
+
return !!tests.find((t) => t.substring(1) === m);
|
110
|
+
};
|
111
|
+
const filtered = methods.filter((m) => !doesMatch(m));
|
112
|
+
tests = filtered;
|
113
|
+
}
|
101
114
|
const toRun = tests !== null && tests !== void 0 ? tests : methods;
|
102
115
|
for (const method of toRun) {
|
103
116
|
try {
|
@@ -124,7 +137,7 @@ const databaseAssertUtil = {
|
|
124
137
|
const count = await db.count(this.collectionName, updates);
|
125
138
|
test_utils_1.assert.isEqual(count, expectedUpdateCount);
|
126
139
|
},
|
127
|
-
async
|
140
|
+
async assertGeneratesIdDifferentEachTime(connect) {
|
128
141
|
const db = await connectToDabatase(connect);
|
129
142
|
const id1 = db.generateId();
|
130
143
|
const id2 = db.generateId();
|
@@ -41,6 +41,7 @@ export type TestConnect = (connectionString?: string, dbName?: string) => Promis
|
|
41
41
|
export interface IndexWithFilter {
|
42
42
|
fields: string[];
|
43
43
|
filter?: Record<string, any>;
|
44
|
+
name?: string;
|
44
45
|
}
|
45
46
|
export type Index = string[] | IndexWithFilter;
|
46
47
|
export interface CreateOptions extends DatabaseInternalOptions {
|