@sprucelabs/data-stores 22.1.0 → 22.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.
Files changed (30) hide show
  1. package/README.md +1 -0
  2. package/build/.spruce/errors/dataStores/notImplemented.schema.d.ts +3 -0
  3. package/build/.spruce/errors/dataStores/notImplemented.schema.js +11 -0
  4. package/build/.spruce/errors/errors.types.d.ts +11 -0
  5. package/build/.spruce/errors/options.types.d.ts +4 -1
  6. package/build/databases/MongoDatabase.d.ts +1 -0
  7. package/build/databases/MongoDatabase.js +5 -0
  8. package/build/databases/NeDbDatabase.d.ts +1 -0
  9. package/build/databases/NeDbDatabase.js +5 -0
  10. package/build/errors/SpruceError.js +3 -0
  11. package/build/errors/notImplemented.builder.d.ts +6 -0
  12. package/build/errors/notImplemented.builder.js +8 -0
  13. package/build/esm/.spruce/errors/errors.types.d.ts +11 -0
  14. package/build/esm/.spruce/errors/options.types.d.ts +4 -1
  15. package/build/esm/databases/MongoDatabase.d.ts +1 -0
  16. package/build/esm/databases/MongoDatabase.js +7 -0
  17. package/build/esm/databases/NeDbDatabase.d.ts +1 -0
  18. package/build/esm/databases/NeDbDatabase.js +7 -0
  19. package/build/esm/errors/SpruceError.js +3 -0
  20. package/build/esm/errors/notImplemented.builder.d.ts +6 -0
  21. package/build/esm/errors/notImplemented.builder.js +6 -0
  22. package/build/esm/tests/databaseAssertUtil.d.ts +1 -1
  23. package/build/esm/tests/databaseAssertUtil.js +19 -2
  24. package/build/esm/tests/pluckAssertionMethods.d.ts +1 -1
  25. package/build/esm/types/database.types.d.ts +1 -0
  26. package/build/tests/databaseAssertUtil.d.ts +1 -1
  27. package/build/tests/databaseAssertUtil.js +19 -2
  28. package/build/tests/pluckAssertionMethods.d.ts +1 -1
  29. package/build/types/database.types.d.ts +1 -0
  30. package/package.json +1 -1
package/README.md CHANGED
@@ -15,6 +15,7 @@ Spruce XP Documentation
15
15
  </p>
16
16
 
17
17
  <br />
18
+
18
19
  <p align="center">
19
20
  <a href="https://developer.spruce.ai/#/"><img width="250" src="https://raw.githubusercontent.com/sprucelabsai/data-stores/master/docs/images/read-full-docs.png" /></a>
20
21
  </p>
@@ -0,0 +1,3 @@
1
+ import { SpruceErrors } from '../errors.types';
2
+ declare const notImplementedSchema: SpruceErrors.DataStores.NotImplementedSchema;
3
+ export default notImplementedSchema;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const schema_1 = require("@sprucelabs/schema");
4
+ const notImplementedSchema = {
5
+ id: 'notImplemented',
6
+ namespace: 'DataStores',
7
+ name: 'Not implemented',
8
+ fields: {}
9
+ };
10
+ schema_1.SchemaRegistry.getInstance().trackSchema(notImplementedSchema);
11
+ exports.default = notImplementedSchema;
@@ -134,6 +134,17 @@ export declare namespace SpruceErrors.DataStores {
134
134
  }
135
135
  type RecordNotFoundEntity = SchemaEntity<SpruceErrors.DataStores.RecordNotFoundSchema>;
136
136
  }
137
+ export declare namespace SpruceErrors.DataStores {
138
+ interface NotImplemented {
139
+ }
140
+ interface NotImplementedSchema extends SpruceSchema.Schema {
141
+ id: 'notImplemented';
142
+ namespace: 'DataStores';
143
+ name: 'Not implemented';
144
+ fields: {};
145
+ }
146
+ type NotImplementedEntity = SchemaEntity<SpruceErrors.DataStores.NotImplementedSchema>;
147
+ }
137
148
  export declare namespace SpruceErrors.DataStores {
138
149
  interface MongoIdMappingError {
139
150
  }
@@ -18,6 +18,9 @@ export interface ScrambleNotConfiguredErrorOptions extends SpruceErrors.DataStor
18
18
  export interface RecordNotFoundErrorOptions extends SpruceErrors.DataStores.RecordNotFound, ISpruceErrorOptions {
19
19
  code: 'RECORD_NOT_FOUND';
20
20
  }
21
+ export interface NotImplementedErrorOptions extends SpruceErrors.DataStores.NotImplemented, ISpruceErrorOptions {
22
+ code: 'NOT_IMPLEMENTED';
23
+ }
21
24
  export interface MongoIdMappingErrorErrorOptions extends SpruceErrors.DataStores.MongoIdMappingError, ISpruceErrorOptions {
22
25
  code: 'MONGO_ID_MAPPING_ERROR';
23
26
  }
@@ -57,5 +60,5 @@ export interface DuplicateKeyErrorOptions extends SpruceErrors.DataStores.Duplic
57
60
  export interface DatabaseNotConnectedErrorOptions extends SpruceErrors.DataStores.DatabaseNotConnected, ISpruceErrorOptions {
58
61
  code: 'DATABASE_NOT_CONNECTED';
59
62
  }
60
- type ErrorOptions = UnknownStoreErrorErrorOptions | UnknownErrorErrorOptions | UnknownDatabaseErrorErrorOptions | UnableToConnectToDbErrorOptions | ScrambleNotConfiguredErrorOptions | RecordNotFoundErrorOptions | MongoIdMappingErrorErrorOptions | InvalidStoreNameErrorOptions | InvalidStoreErrorOptions | InvalidDbConnectionStringErrorOptions | InvalidDatabaseNameErrorOptions | InvalidConnectionStringSchemeErrorOptions | IndexNotFoundErrorOptions | IndexExistsErrorOptions | FailedToLoadStoresErrorOptions | FailedToLoadStoreErrorOptions | DuplicateRecordErrorOptions | DuplicateKeyErrorOptions | DatabaseNotConnectedErrorOptions;
63
+ type ErrorOptions = UnknownStoreErrorErrorOptions | UnknownErrorErrorOptions | UnknownDatabaseErrorErrorOptions | UnableToConnectToDbErrorOptions | ScrambleNotConfiguredErrorOptions | RecordNotFoundErrorOptions | NotImplementedErrorOptions | MongoIdMappingErrorErrorOptions | InvalidStoreNameErrorOptions | InvalidStoreErrorOptions | InvalidDbConnectionStringErrorOptions | InvalidDatabaseNameErrorOptions | InvalidConnectionStringSchemeErrorOptions | IndexNotFoundErrorOptions | IndexExistsErrorOptions | FailedToLoadStoresErrorOptions | FailedToLoadStoreErrorOptions | DuplicateRecordErrorOptions | DuplicateKeyErrorOptions | DatabaseNotConnectedErrorOptions;
61
64
  export default ErrorOptions;
@@ -39,4 +39,5 @@ export default class MongoDatabase implements Database {
39
39
  updateOne(collection: string, query: Record<string, any>, updates: Record<string, any>): Promise<Record<string, any>>;
40
40
  upsertOne(collection: string, query: Record<string, any>, updates: Record<string, any>): Promise<Record<string, any>>;
41
41
  private generateDuplicateFieldsForError;
42
+ query<T>(): Promise<T>;
42
43
  }
@@ -441,5 +441,10 @@ class MongoDatabase {
441
441
  duplicateValues,
442
442
  };
443
443
  }
444
+ async query() {
445
+ throw new SpruceError_1.default({
446
+ code: 'NOT_IMPLEMENTED',
447
+ });
448
+ }
444
449
  }
445
450
  exports.default = MongoDatabase;
@@ -38,4 +38,5 @@ export default class NeDbDatabase extends AbstractMutexer implements Database {
38
38
  createIndex(collection: string, fields: string[]): Promise<void>;
39
39
  syncUniqueIndexes(collectionName: string, indexes: string[][]): Promise<void>;
40
40
  syncIndexes(collectionName: string, indexes: string[][]): Promise<void>;
41
+ query<T>(): Promise<T>;
41
42
  }
@@ -451,5 +451,10 @@ class NeDbDatabase extends AbstractMutexer_1.default {
451
451
  await this.dropIndex(collectionName, extra);
452
452
  }
453
453
  }
454
+ async query() {
455
+ throw new SpruceError_1.default({
456
+ code: 'NOT_IMPLEMENTED',
457
+ });
458
+ }
454
459
  }
455
460
  exports.default = NeDbDatabase;
@@ -99,6 +99,9 @@ If you are on a mac, using brew is recommended: https://brew.sh`;
99
99
  case 'INVALID_CONNECTION_STRING_SCHEME':
100
100
  message = `There is no database adapter setup for: ${options.connectionString.split('://')[0]}`;
101
101
  break;
102
+ case 'NOT_IMPLEMENTED':
103
+ message = 'A Not implemented just happened!';
104
+ break;
102
105
  default:
103
106
  message = super.friendlyMessage();
104
107
  }
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ id: string;
3
+ name: string;
4
+ fields: {};
5
+ };
6
+ export default _default;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const schema_1 = require("@sprucelabs/schema");
4
+ exports.default = (0, schema_1.buildErrorSchema)({
5
+ id: 'notImplemented',
6
+ name: 'Not implemented',
7
+ fields: {},
8
+ });
@@ -134,6 +134,17 @@ export declare namespace SpruceErrors.DataStores {
134
134
  }
135
135
  type RecordNotFoundEntity = SchemaEntity<SpruceErrors.DataStores.RecordNotFoundSchema>;
136
136
  }
137
+ export declare namespace SpruceErrors.DataStores {
138
+ interface NotImplemented {
139
+ }
140
+ interface NotImplementedSchema extends SpruceSchema.Schema {
141
+ id: 'notImplemented';
142
+ namespace: 'DataStores';
143
+ name: 'Not implemented';
144
+ fields: {};
145
+ }
146
+ type NotImplementedEntity = SchemaEntity<SpruceErrors.DataStores.NotImplementedSchema>;
147
+ }
137
148
  export declare namespace SpruceErrors.DataStores {
138
149
  interface MongoIdMappingError {
139
150
  }
@@ -18,6 +18,9 @@ export interface ScrambleNotConfiguredErrorOptions extends SpruceErrors.DataStor
18
18
  export interface RecordNotFoundErrorOptions extends SpruceErrors.DataStores.RecordNotFound, ISpruceErrorOptions {
19
19
  code: 'RECORD_NOT_FOUND';
20
20
  }
21
+ export interface NotImplementedErrorOptions extends SpruceErrors.DataStores.NotImplemented, ISpruceErrorOptions {
22
+ code: 'NOT_IMPLEMENTED';
23
+ }
21
24
  export interface MongoIdMappingErrorErrorOptions extends SpruceErrors.DataStores.MongoIdMappingError, ISpruceErrorOptions {
22
25
  code: 'MONGO_ID_MAPPING_ERROR';
23
26
  }
@@ -57,5 +60,5 @@ export interface DuplicateKeyErrorOptions extends SpruceErrors.DataStores.Duplic
57
60
  export interface DatabaseNotConnectedErrorOptions extends SpruceErrors.DataStores.DatabaseNotConnected, ISpruceErrorOptions {
58
61
  code: 'DATABASE_NOT_CONNECTED';
59
62
  }
60
- type ErrorOptions = UnknownStoreErrorErrorOptions | UnknownErrorErrorOptions | UnknownDatabaseErrorErrorOptions | UnableToConnectToDbErrorOptions | ScrambleNotConfiguredErrorOptions | RecordNotFoundErrorOptions | MongoIdMappingErrorErrorOptions | InvalidStoreNameErrorOptions | InvalidStoreErrorOptions | InvalidDbConnectionStringErrorOptions | InvalidDatabaseNameErrorOptions | InvalidConnectionStringSchemeErrorOptions | IndexNotFoundErrorOptions | IndexExistsErrorOptions | FailedToLoadStoresErrorOptions | FailedToLoadStoreErrorOptions | DuplicateRecordErrorOptions | DuplicateKeyErrorOptions | DatabaseNotConnectedErrorOptions;
63
+ type ErrorOptions = UnknownStoreErrorErrorOptions | UnknownErrorErrorOptions | UnknownDatabaseErrorErrorOptions | UnableToConnectToDbErrorOptions | ScrambleNotConfiguredErrorOptions | RecordNotFoundErrorOptions | NotImplementedErrorOptions | MongoIdMappingErrorErrorOptions | InvalidStoreNameErrorOptions | InvalidStoreErrorOptions | InvalidDbConnectionStringErrorOptions | InvalidDatabaseNameErrorOptions | InvalidConnectionStringSchemeErrorOptions | IndexNotFoundErrorOptions | IndexExistsErrorOptions | FailedToLoadStoresErrorOptions | FailedToLoadStoreErrorOptions | DuplicateRecordErrorOptions | DuplicateKeyErrorOptions | DatabaseNotConnectedErrorOptions;
61
64
  export default ErrorOptions;
@@ -39,4 +39,5 @@ export default class MongoDatabase implements Database {
39
39
  updateOne(collection: string, query: Record<string, any>, updates: Record<string, any>): Promise<Record<string, any>>;
40
40
  upsertOne(collection: string, query: Record<string, any>, updates: Record<string, any>): Promise<Record<string, any>>;
41
41
  private generateDuplicateFieldsForError;
42
+ query<T>(): Promise<T>;
42
43
  }
@@ -486,4 +486,11 @@ export default class MongoDatabase {
486
486
  duplicateValues,
487
487
  };
488
488
  }
489
+ query() {
490
+ return __awaiter(this, void 0, void 0, function* () {
491
+ throw new SpruceError({
492
+ code: 'NOT_IMPLEMENTED',
493
+ });
494
+ });
495
+ }
489
496
  }
@@ -38,4 +38,5 @@ export default class NeDbDatabase extends AbstractMutexer implements Database {
38
38
  createIndex(collection: string, fields: string[]): Promise<void>;
39
39
  syncUniqueIndexes(collectionName: string, indexes: string[][]): Promise<void>;
40
40
  syncIndexes(collectionName: string, indexes: string[][]): Promise<void>;
41
+ query<T>(): Promise<T>;
41
42
  }
@@ -501,4 +501,11 @@ export default class NeDbDatabase extends AbstractMutexer {
501
501
  }
502
502
  });
503
503
  }
504
+ query() {
505
+ return __awaiter(this, void 0, void 0, function* () {
506
+ throw new SpruceError({
507
+ code: 'NOT_IMPLEMENTED',
508
+ });
509
+ });
510
+ }
504
511
  }
@@ -94,6 +94,9 @@ If you are on a mac, using brew is recommended: https://brew.sh`;
94
94
  case 'INVALID_CONNECTION_STRING_SCHEME':
95
95
  message = `There is no database adapter setup for: ${options.connectionString.split('://')[0]}`;
96
96
  break;
97
+ case 'NOT_IMPLEMENTED':
98
+ message = 'A Not implemented just happened!';
99
+ break;
97
100
  default:
98
101
  message = super.friendlyMessage();
99
102
  }
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ id: string;
3
+ name: string;
4
+ fields: {};
5
+ };
6
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import { buildErrorSchema } from '@sprucelabs/schema';
2
+ export default buildErrorSchema({
3
+ id: 'notImplemented',
4
+ name: 'Not implemented',
5
+ fields: {},
6
+ });
@@ -53,7 +53,7 @@ declare const databaseAssertUtil: {
53
53
  assertThrowsWithInvalidConnectionString(connect: TestConnect): Promise<void>;
54
54
  assertKnowsIfConnectionClosed(connect: TestConnect): Promise<void>;
55
55
  assertCanQueryPathWithDotSyntax(connect: TestConnect): Promise<void>;
56
- assertCanQueryByGtLtGteLte(connect: TestConnect): Promise<void>;
56
+ assertCanQueryByGtLtGteLteNe(connect: TestConnect): Promise<void>;
57
57
  assertCanFindWithNe(connect: TestConnect): Promise<void>;
58
58
  assertCanFindWithIn(connect: TestConnect): Promise<void>;
59
59
  assertCanFindWithBooleanField(connect: TestConnect): Promise<void>;
@@ -55,7 +55,7 @@ const databaseAssertUtil = {
55
55
  'assertCanLimitResults',
56
56
  'assertCanLimitResultsToZero',
57
57
  'assertCanFindWithBooleanField',
58
- 'assertCanQueryByGtLtGteLte',
58
+ 'assertCanQueryByGtLtGteLteNe',
59
59
  'assertCanQueryPathWithDotSyntax',
60
60
  'assertCanReturnOnlySelectFields',
61
61
  'assertCanSearchByRegex',
@@ -1162,25 +1162,29 @@ const databaseAssertUtil = {
1162
1162
  yield this.shutdown(db);
1163
1163
  });
1164
1164
  },
1165
- assertCanQueryByGtLtGteLte(connect) {
1165
+ assertCanQueryByGtLtGteLteNe(connect) {
1166
1166
  return __awaiter(this, void 0, void 0, function* () {
1167
1167
  const db = yield connectToDabatase(connect);
1168
1168
  const created = yield db.create(this.collectionName, [
1169
1169
  {
1170
1170
  number: 1,
1171
1171
  name: generateId(),
1172
+ someField: null,
1172
1173
  },
1173
1174
  {
1174
1175
  number: 2,
1175
1176
  name: generateId(),
1177
+ someField: 'test',
1176
1178
  },
1177
1179
  {
1178
1180
  number: 3,
1179
1181
  name: generateId(),
1182
+ someField: 'test',
1180
1183
  },
1181
1184
  {
1182
1185
  number: 4,
1183
1186
  name: generateId(),
1187
+ someField: 'test',
1184
1188
  },
1185
1189
  ]);
1186
1190
  const gtMatches = yield db.find(this.collectionName, {
@@ -1207,6 +1211,19 @@ const databaseAssertUtil = {
1207
1211
  assert.isEqual(lteMatches[0].number, 1);
1208
1212
  assert.isEqual(lteMatches[1].number, 2);
1209
1213
  assert.isEqual(lteMatches[2].number, 3);
1214
+ const notMatches = yield db.find(this.collectionName, {
1215
+ id: {
1216
+ $ne: created[0].id,
1217
+ },
1218
+ });
1219
+ assert.isNotEqual(notMatches[0].id, created[0].id);
1220
+ assert.isLength(notMatches, created.length - 1);
1221
+ const notNull = yield db.find(this.collectionName, {
1222
+ someField: {
1223
+ $ne: null,
1224
+ },
1225
+ });
1226
+ assert.isLength(notNull, created.length - 1);
1210
1227
  yield this.shutdown(db);
1211
1228
  });
1212
1229
  },
@@ -1,2 +1,2 @@
1
1
  import databaseAssertUtil from './databaseAssertUtil';
2
- export default function pluckAssertionMethods(util: typeof databaseAssertUtil): ("collectionName" | "assertThrowsWithInvalidConnectionString" | "assertThrowsWhenCantConnect" | "assertThrowsWithBadDatabaseName" | "assertEmptyDatabaseReturnsEmptyArray" | "assertKnowsIfConnectionClosed" | "assertFindOneOnEmptyDatabaseReturnsNull" | "assertCanSortDesc" | "assertCanSortAsc" | "assertCanSortById" | "assertCanQueryWithOr" | "generateIdDifferentEachTime" | "assertInsertingGeneratesId" | "assertCanCreateMany" | "assertCanLimitResults" | "assertCanCreateWithObjectField" | "assertCanCountOnId" | "assertCanCount" | "assertThrowsWhenUpdatingRecordNotFound" | "assertCanUpdate" | "assertCanUpdateMany" | "assertCanPushOntoArrayValue" | "canUpdateWithObjectField" | "canUpdateFieldInObjectFieldWithTargettedWhere" | "assertCanSaveAndGetNullAndUndefined" | "assertCanUpsertOne" | "assertCanUpsertNull" | "assertCanPushToArrayOnUpsert" | "assertCanLimitResultsToZero" | "assertCanFindWithBooleanField" | "assertCanQueryByGtLtGteLte" | "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" | "runSuite" | "_getFilteredIndexes" | "_filterIdIndex" | "_assertUpdateUpdatedRightNumberOfRecords" | "shutdown" | "_assertThrowsExpectedNotFoundOnUpdateOne" | "_assert$orReturnsExpectedTotalRecords" | "_assertCanCreateMultiFieldIndex")[];
2
+ export default function pluckAssertionMethods(util: typeof databaseAssertUtil): ("collectionName" | "assertThrowsWithInvalidConnectionString" | "assertThrowsWhenCantConnect" | "assertThrowsWithBadDatabaseName" | "assertEmptyDatabaseReturnsEmptyArray" | "assertKnowsIfConnectionClosed" | "assertFindOneOnEmptyDatabaseReturnsNull" | "assertCanSortDesc" | "assertCanSortAsc" | "assertCanSortById" | "assertCanQueryWithOr" | "generateIdDifferentEachTime" | "assertInsertingGeneratesId" | "assertCanCreateMany" | "assertCanLimitResults" | "assertCanCreateWithObjectField" | "assertCanCountOnId" | "assertCanCount" | "assertThrowsWhenUpdatingRecordNotFound" | "assertCanUpdate" | "assertCanUpdateMany" | "assertCanPushOntoArrayValue" | "canUpdateWithObjectField" | "canUpdateFieldInObjectFieldWithTargettedWhere" | "assertCanSaveAndGetNullAndUndefined" | "assertCanUpsertOne" | "assertCanUpsertNull" | "assertCanPushToArrayOnUpsert" | "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" | "runSuite" | "_getFilteredIndexes" | "_filterIdIndex" | "_assertUpdateUpdatedRightNumberOfRecords" | "shutdown" | "_assertThrowsExpectedNotFoundOnUpdateOne" | "_assert$orReturnsExpectedTotalRecords" | "_assertCanCreateMultiFieldIndex")[];
@@ -27,6 +27,7 @@ export interface Database {
27
27
  count(collection: string, query?: Record<string, any>): Promise<number>;
28
28
  createUniqueIndex(collection: string, fields: UniqueIndex): Promise<void>;
29
29
  createIndex(collection: string, fields: Index): Promise<void>;
30
+ query<T>(query: string): Promise<T>;
30
31
  }
31
32
  export interface DatabaseOptions {
32
33
  dbName?: string;
@@ -53,7 +53,7 @@ declare const databaseAssertUtil: {
53
53
  assertThrowsWithInvalidConnectionString(connect: TestConnect): Promise<void>;
54
54
  assertKnowsIfConnectionClosed(connect: TestConnect): Promise<void>;
55
55
  assertCanQueryPathWithDotSyntax(connect: TestConnect): Promise<void>;
56
- assertCanQueryByGtLtGteLte(connect: TestConnect): Promise<void>;
56
+ assertCanQueryByGtLtGteLteNe(connect: TestConnect): Promise<void>;
57
57
  assertCanFindWithNe(connect: TestConnect): Promise<void>;
58
58
  assertCanFindWithIn(connect: TestConnect): Promise<void>;
59
59
  assertCanFindWithBooleanField(connect: TestConnect): Promise<void>;
@@ -50,7 +50,7 @@ const databaseAssertUtil = {
50
50
  'assertCanLimitResults',
51
51
  'assertCanLimitResultsToZero',
52
52
  'assertCanFindWithBooleanField',
53
- 'assertCanQueryByGtLtGteLte',
53
+ 'assertCanQueryByGtLtGteLteNe',
54
54
  'assertCanQueryPathWithDotSyntax',
55
55
  'assertCanReturnOnlySelectFields',
56
56
  'assertCanSearchByRegex',
@@ -1056,24 +1056,28 @@ const databaseAssertUtil = {
1056
1056
  test_utils_1.assert.isEqual(secondMatch.name, 'second');
1057
1057
  await this.shutdown(db);
1058
1058
  },
1059
- async assertCanQueryByGtLtGteLte(connect) {
1059
+ async assertCanQueryByGtLtGteLteNe(connect) {
1060
1060
  const db = await connectToDabatase(connect);
1061
1061
  const created = await db.create(this.collectionName, [
1062
1062
  {
1063
1063
  number: 1,
1064
1064
  name: (0, generateId_1.default)(),
1065
+ someField: null,
1065
1066
  },
1066
1067
  {
1067
1068
  number: 2,
1068
1069
  name: (0, generateId_1.default)(),
1070
+ someField: 'test',
1069
1071
  },
1070
1072
  {
1071
1073
  number: 3,
1072
1074
  name: (0, generateId_1.default)(),
1075
+ someField: 'test',
1073
1076
  },
1074
1077
  {
1075
1078
  number: 4,
1076
1079
  name: (0, generateId_1.default)(),
1080
+ someField: 'test',
1077
1081
  },
1078
1082
  ]);
1079
1083
  const gtMatches = await db.find(this.collectionName, {
@@ -1100,6 +1104,19 @@ const databaseAssertUtil = {
1100
1104
  test_utils_1.assert.isEqual(lteMatches[0].number, 1);
1101
1105
  test_utils_1.assert.isEqual(lteMatches[1].number, 2);
1102
1106
  test_utils_1.assert.isEqual(lteMatches[2].number, 3);
1107
+ const notMatches = await db.find(this.collectionName, {
1108
+ id: {
1109
+ $ne: created[0].id,
1110
+ },
1111
+ });
1112
+ test_utils_1.assert.isNotEqual(notMatches[0].id, created[0].id);
1113
+ test_utils_1.assert.isLength(notMatches, created.length - 1);
1114
+ const notNull = await db.find(this.collectionName, {
1115
+ someField: {
1116
+ $ne: null,
1117
+ },
1118
+ });
1119
+ test_utils_1.assert.isLength(notNull, created.length - 1);
1103
1120
  await this.shutdown(db);
1104
1121
  },
1105
1122
  async assertCanFindWithNe(connect) {
@@ -1,2 +1,2 @@
1
1
  import databaseAssertUtil from './databaseAssertUtil';
2
- export default function pluckAssertionMethods(util: typeof databaseAssertUtil): ("collectionName" | "assertThrowsWithInvalidConnectionString" | "assertThrowsWhenCantConnect" | "assertThrowsWithBadDatabaseName" | "assertEmptyDatabaseReturnsEmptyArray" | "assertKnowsIfConnectionClosed" | "assertFindOneOnEmptyDatabaseReturnsNull" | "assertCanSortDesc" | "assertCanSortAsc" | "assertCanSortById" | "assertCanQueryWithOr" | "generateIdDifferentEachTime" | "assertInsertingGeneratesId" | "assertCanCreateMany" | "assertCanLimitResults" | "assertCanCreateWithObjectField" | "assertCanCountOnId" | "assertCanCount" | "assertThrowsWhenUpdatingRecordNotFound" | "assertCanUpdate" | "assertCanUpdateMany" | "assertCanPushOntoArrayValue" | "canUpdateWithObjectField" | "canUpdateFieldInObjectFieldWithTargettedWhere" | "assertCanSaveAndGetNullAndUndefined" | "assertCanUpsertOne" | "assertCanUpsertNull" | "assertCanPushToArrayOnUpsert" | "assertCanLimitResultsToZero" | "assertCanFindWithBooleanField" | "assertCanQueryByGtLtGteLte" | "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" | "runSuite" | "_getFilteredIndexes" | "_filterIdIndex" | "_assertUpdateUpdatedRightNumberOfRecords" | "shutdown" | "_assertThrowsExpectedNotFoundOnUpdateOne" | "_assert$orReturnsExpectedTotalRecords" | "_assertCanCreateMultiFieldIndex")[];
2
+ export default function pluckAssertionMethods(util: typeof databaseAssertUtil): ("collectionName" | "assertThrowsWithInvalidConnectionString" | "assertThrowsWhenCantConnect" | "assertThrowsWithBadDatabaseName" | "assertEmptyDatabaseReturnsEmptyArray" | "assertKnowsIfConnectionClosed" | "assertFindOneOnEmptyDatabaseReturnsNull" | "assertCanSortDesc" | "assertCanSortAsc" | "assertCanSortById" | "assertCanQueryWithOr" | "generateIdDifferentEachTime" | "assertInsertingGeneratesId" | "assertCanCreateMany" | "assertCanLimitResults" | "assertCanCreateWithObjectField" | "assertCanCountOnId" | "assertCanCount" | "assertThrowsWhenUpdatingRecordNotFound" | "assertCanUpdate" | "assertCanUpdateMany" | "assertCanPushOntoArrayValue" | "canUpdateWithObjectField" | "canUpdateFieldInObjectFieldWithTargettedWhere" | "assertCanSaveAndGetNullAndUndefined" | "assertCanUpsertOne" | "assertCanUpsertNull" | "assertCanPushToArrayOnUpsert" | "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" | "runSuite" | "_getFilteredIndexes" | "_filterIdIndex" | "_assertUpdateUpdatedRightNumberOfRecords" | "shutdown" | "_assertThrowsExpectedNotFoundOnUpdateOne" | "_assert$orReturnsExpectedTotalRecords" | "_assertCanCreateMultiFieldIndex")[];
@@ -27,6 +27,7 @@ export interface Database {
27
27
  count(collection: string, query?: Record<string, any>): Promise<number>;
28
28
  createUniqueIndex(collection: string, fields: UniqueIndex): Promise<void>;
29
29
  createIndex(collection: string, fields: Index): Promise<void>;
30
+ query<T>(query: string): Promise<T>;
30
31
  }
31
32
  export interface DatabaseOptions {
32
33
  dbName?: string;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "22.1.0",
6
+ "version": "22.3.0",
7
7
  "files": [
8
8
  "build/**/*",
9
9
  "!build/__tests__",