@orion-js/mongodb 3.0.41 → 3.0.42

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.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadIndexes = exports.checkIndexes = void 0;
4
+ const mongodb_1 = require("mongodb");
4
5
  function matchingDefinition(defIndex, curIndex) {
5
6
  if (defIndex.options && defIndex.options.name === curIndex.name)
6
7
  return true;
@@ -49,6 +50,10 @@ async function loadIndexes(collection) {
49
50
  console.info('Index updated correctly');
50
51
  return result;
51
52
  }
53
+ else if (error instanceof mongodb_1.MongoExpiredSessionError) {
54
+ // this errors is thrown when we are on tests environment
55
+ // but it's not a problem never, index will be created on the next connection
56
+ }
52
57
  else {
53
58
  console.error(`Error creating index for collection ${collection.name}: ${error.message}`);
54
59
  console.error(error);
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const helpers_1 = require("@orion-js/helpers");
7
+ const _1 = __importDefault(require("."));
8
+ const Tests = (0, _1.default)({
9
+ name: (0, helpers_1.generateId)(),
10
+ indexes: [{ keys: { a: 1 }, options: { unique: true } }]
11
+ });
12
+ describe('createIndexesPromise', () => {
13
+ it('should correctly handle the promise for tests', async () => {
14
+ const userId = await Tests.insertOne({
15
+ name: 'Nico'
16
+ });
17
+ const user = await Tests.findOne(userId);
18
+ expect(user.name).toBe('Nico');
19
+ });
20
+ it('should be able to close the index handlers on the global config', async () => {
21
+ (0, _1.default)({
22
+ name: (0, helpers_1.generateId)(),
23
+ indexes: [{ keys: { a: 1 }, options: { unique: true } }]
24
+ });
25
+ });
26
+ });
@@ -9,6 +9,10 @@ beforeAll(async () => {
9
9
  await connection.connectionPromise;
10
10
  });
11
11
  afterAll(async () => {
12
+ /**
13
+ * We need to wait on indexes promises to be resolved to close all the handlers
14
+ */
15
+ await Promise.all(__1.createIndexesPromises);
12
16
  for (const connectionName in connections_1.connections) {
13
17
  const connection = connections_1.connections[connectionName];
14
18
  await connection.client.close();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-js/mongodb",
3
- "version": "3.0.41",
3
+ "version": "3.0.42",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "files": [
@@ -38,5 +38,5 @@
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "9b3b84b2e968a20ecf45d252201ad911f12c8aa0"
41
+ "gitHead": "ef0e7a088474c899e13146be867dc574032ac588"
42
42
  }