cosa 6.2.0 → 6.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 (2) hide show
  1. package/lib/session.js +7 -11
  2. package/package.json +6 -6
package/lib/session.js CHANGED
@@ -10,19 +10,17 @@ const createSession = async () => {
10
10
  const session = await db._client.startSession();
11
11
 
12
12
  const abortTransaction = async () => {
13
- let error;
13
+ const errors = [];
14
14
  await session.abortTransaction();
15
15
  await session.endSession();
16
16
  await forEachSerialP(async (afterAborted) => {
17
17
  try {
18
- await afterAborted(error);
18
+ await afterAborted();
19
19
  } catch (err) {
20
- if (!err) {
21
- error = err;
22
- }
20
+ errors.push(err);
23
21
  }
24
22
  }, afterAborts);
25
- if (error) { throw error; }
23
+ return { errors };
26
24
  };
27
25
 
28
26
  return {
@@ -33,19 +31,17 @@ const createSession = async () => {
33
31
  return session.startTransaction();
34
32
  },
35
33
  commitTransaction: async () => {
36
- let error;
34
+ const errors = [];
37
35
  await session.commitTransaction();
38
36
  await session.endSession();
39
37
  await forEachSerialP(async (afterCommitFunc) => {
40
38
  try {
41
39
  await afterCommitFunc();
42
40
  } catch (err) {
43
- if (!error) {
44
- error = err;
45
- }
41
+ errors.push(err);
46
42
  }
47
43
  }, afterCommits);
48
- if (error) { throw error; }
44
+ return { errors };
49
45
  },
50
46
  abortTransaction,
51
47
  afterCommits,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cosa",
3
- "version": "6.2.0",
3
+ "version": "6.3.0",
4
4
  "description": "Cosa Models for MongoDB",
5
5
  "main": "lib/index.js",
6
6
  "engines": {
@@ -35,24 +35,24 @@
35
35
  "lib"
36
36
  ],
37
37
  "dependencies": {
38
- "bson": "~4.6.4",
38
+ "bson": "~4.7.0",
39
39
  "clone": "^2.1.2",
40
40
  "debug": "^4.3.4",
41
41
  "error": "^7.0.2",
42
42
  "etag": "^1.8.1",
43
43
  "@hapi/joi": "^17.1.1",
44
- "mongodb": "~4.7.0",
44
+ "mongodb": "~4.10.0",
45
45
  "object-path": "^0.11.8",
46
46
  "omnibelt": "^2.1.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@losant/eslint-config-losant": "^1.4.3",
49
+ "@losant/eslint-config-losant": "^1.4.4",
50
50
  "husky": "^8.0.1",
51
- "lint-staged": "^13.0.2",
51
+ "lint-staged": "^13.0.3",
52
52
  "chai": "^4.3.6",
53
53
  "chai-as-promised": "^7.1.1",
54
54
  "chai-datetime": "^1.8.0",
55
- "documentation": "^13.2.5",
55
+ "documentation": "^14.0.0",
56
56
  "mocha": "^10.0.0",
57
57
  "string-template": "^1.0.0"
58
58
  },