@orion-js/mongodb 3.1.6 → 3.1.12

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.
@@ -2,17 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getMongoURLFromEnv = void 0;
4
4
  const connections_1 = require("./connections");
5
+ const env_1 = require("@orion-js/env");
5
6
  const getMongoURLFromEnv = (connectionName) => {
6
7
  if (connectionName === 'main') {
7
- if (!process.env.MONGO_URL) {
8
+ if (!(0, env_1.internalGetEnv)('mongo_url', 'MONGO_URL')) {
8
9
  throw new Error('MONGO_URL is required');
9
10
  }
10
- return process.env.MONGO_URL;
11
+ return (0, env_1.internalGetEnv)('mongo_url', 'MONGO_URL');
11
12
  }
12
- const name = `MONGO_URL_${connectionName.toUpperCase()}`;
13
- const uri = connections_1.connections[connectionName]?.uri ?? process.env[name];
13
+ const envName = `mongo_url_${connectionName.toLowerCase()}`;
14
+ const processEnvName = `MONGO_URL_${connectionName.toUpperCase()}`;
15
+ const uri = connections_1.connections[connectionName]?.uri ?? (0, env_1.internalGetEnv)(envName, processEnvName);
14
16
  if (!uri) {
15
- throw new Error(`To use the connection "${connectionName}" you must initialize it first calling getMongoConnection({name: "${connectionName}", uri: "MONGOURI"}) or setting the environment variable ${name}.`);
17
+ throw new Error(`To use the connection "${connectionName}" you must initialize it first calling getMongoConnection({name: "${connectionName}", uri: "MONGOURI"}) or setting the environment variable ${processEnvName}.`);
16
18
  }
17
19
  return uri;
18
20
  };
@@ -7,6 +7,7 @@ const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
7
7
  const lodash_1 = require("lodash");
8
8
  const fromDot_1 = __importDefault(require("../../helpers/fromDot"));
9
9
  const schema_1 = require("@orion-js/schema");
10
+ const wrapErrors_1 = require("./wrapErrors");
10
11
  exports.default = (collection) => {
11
12
  const insertMany = async (docs, options = {}) => {
12
13
  for (let index = 0; index < docs.length; index++) {
@@ -24,7 +25,9 @@ exports.default = (collection) => {
24
25
  }
25
26
  docs[index] = doc;
26
27
  }
27
- const { insertedIds } = await collection.rawCollection.insertMany(docs, options.mongoOptions);
28
+ const { insertedIds } = await (0, wrapErrors_1.wrapErrors)(() => {
29
+ return collection.rawCollection.insertMany(docs, options.mongoOptions);
30
+ });
28
31
  const ids = (0, lodash_1.values)(insertedIds);
29
32
  return ids.map(id => id.toString());
30
33
  };
@@ -90,7 +90,6 @@ describe('InsertOne', () => {
90
90
  ]
91
91
  });
92
92
  await Tests.createIndexesPromise;
93
- console.log(await Tests.rawCollection.listIndexes().toArray());
94
93
  await Tests.insertOne({ name: 'one' });
95
94
  expect.assertions(3);
96
95
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-js/mongodb",
3
- "version": "3.1.6",
3
+ "version": "3.1.12",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "files": [
@@ -17,11 +17,12 @@
17
17
  "upgrade-interactive": "yarn upgrade-interactive"
18
18
  },
19
19
  "dependencies": {
20
- "@orion-js/helpers": "^3.1.6",
21
- "@orion-js/models": "^3.1.6",
22
- "@orion-js/resolvers": "^3.1.6",
20
+ "@orion-js/env": "^3.1.12",
21
+ "@orion-js/helpers": "^3.1.12",
22
+ "@orion-js/models": "^3.1.12",
23
+ "@orion-js/resolvers": "^3.1.12",
23
24
  "@orion-js/schema": "^3.1.6",
24
- "@orion-js/typed-model": "^3.1.6",
25
+ "@orion-js/typed-model": "^3.1.12",
25
26
  "dataloader": "2.0.0",
26
27
  "dot-object": "2.1.4",
27
28
  "mongodb": "4.1.4"
@@ -38,5 +39,5 @@
38
39
  "publishConfig": {
39
40
  "access": "public"
40
41
  },
41
- "gitHead": "cb180a6a89ee2042f9d3dc80725f3aa05705a963"
42
+ "gitHead": "a6b82a931bea3179dfac4099579096c4f7a780bb"
42
43
  }