@orion-js/mongodb 3.2.18 → 3.2.20

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.
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const getSelector_1 = __importDefault(require("./getSelector"));
7
7
  exports.default = (collection) => {
8
8
  const func = async function (selectorArg, options) {
9
+ await collection.connectionPromise;
9
10
  const selector = (0, getSelector_1.default)(arguments);
10
11
  const result = await collection.rawCollection.countDocuments(selector, options);
11
12
  return result;
@@ -8,6 +8,7 @@ const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
8
8
  const dataLoad_1 = __importDefault(require("./dataLoad"));
9
9
  function default_1(collection) {
10
10
  const loadData = async (options) => {
11
+ await collection.connectionPromise;
11
12
  const result = await (0, dataLoad_1.default)({
12
13
  loaderKey: {
13
14
  key: options.key,
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const getSelector_1 = __importDefault(require("./getSelector"));
7
7
  exports.default = (collection) => {
8
8
  const func = async function (selectorArg, options) {
9
+ await collection.connectionPromise;
9
10
  const selector = (0, getSelector_1.default)(arguments);
10
11
  const result = await collection.rawCollection.deleteMany(selector, options);
11
12
  return result;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const getSelector_1 = __importDefault(require("./getSelector"));
7
7
  exports.default = (collection) => {
8
8
  const func = async function (selectorArg, options) {
9
+ await collection.connectionPromise;
9
10
  const selector = (0, getSelector_1.default)(arguments);
10
11
  const result = await collection.rawCollection.deleteOne(selector, options);
11
12
  return result;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = (collection) => {
4
4
  const func = async function (options) {
5
+ await collection.connectionPromise;
5
6
  const result = await collection.rawCollection.estimatedDocumentCount(options);
6
7
  return result;
7
8
  };
@@ -10,6 +10,7 @@ exports.default = (collection) => {
10
10
  const cursor = collection.rawCollection.find(selector, options);
11
11
  cursor._oldToArray = cursor.toArray;
12
12
  cursor.toArray = async () => {
13
+ await collection.connectionPromise;
13
14
  const items = await cursor._oldToArray();
14
15
  return items.map(item => collection.initItem(item));
15
16
  };
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const getSelector_1 = __importDefault(require("./getSelector"));
7
7
  exports.default = (collection) => {
8
8
  const findOne = async function (selectorArg, options) {
9
+ await collection.connectionPromise;
9
10
  const selector = (0, getSelector_1.default)(arguments);
10
11
  const item = await collection.rawCollection.findOne(selector, options);
11
12
  if (!item)
@@ -8,6 +8,7 @@ const validateModifier_1 = __importDefault(require("./validateModifier"));
8
8
  const cleanModifier_1 = __importDefault(require("./cleanModifier"));
9
9
  exports.default = (collection) => {
10
10
  const findOneAndUpdate = async function (selectorArg, modifierArg, options = {}) {
11
+ await collection.connectionPromise;
11
12
  let modifier = modifierArg;
12
13
  const selector = (0, getSelector_1.default)(arguments);
13
14
  if (!modifier) {
@@ -10,6 +10,7 @@ const schema_1 = require("@orion-js/schema");
10
10
  const wrapErrors_1 = require("./wrapErrors");
11
11
  exports.default = (collection) => {
12
12
  const insertMany = async (docs, options = {}) => {
13
+ await collection.connectionPromise;
13
14
  for (let index = 0; index < docs.length; index++) {
14
15
  let doc = (0, lodash_1.cloneDeep)(docs[index]);
15
16
  if (!doc || !(0, isPlainObject_1.default)(doc)) {
@@ -9,6 +9,7 @@ const schema_1 = require("@orion-js/schema");
9
9
  const wrapErrors_1 = require("./wrapErrors");
10
10
  exports.default = (collection) => {
11
11
  const insertOne = async (insertDoc, options) => {
12
+ await collection.connectionPromise;
12
13
  let doc = insertDoc;
13
14
  if (!doc || !(0, isPlainObject_1.default)(doc)) {
14
15
  throw new Error('Insert must receive a document');
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const wrapErrors_1 = require("./wrapErrors");
4
4
  exports.default = (collection) => {
5
5
  const updateAndFind = async function (selector, modifier, options = {}) {
6
+ await collection.connectionPromise;
6
7
  return await (0, wrapErrors_1.wrapErrors)(async () => {
7
8
  return await collection.findOneAndUpdate(selector, modifier, {
8
9
  ...options,
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const wrapErrors_1 = require("./wrapErrors");
4
4
  exports.default = (collection) => {
5
5
  const updateItem = async function (item, modifier) {
6
+ await collection.connectionPromise;
6
7
  const updated = await (0, wrapErrors_1.wrapErrors)(async () => {
7
8
  return await collection.updateAndFind({ _id: item._id }, modifier);
8
9
  });
@@ -9,6 +9,7 @@ const validateModifier_1 = __importDefault(require("./validateModifier"));
9
9
  const wrapErrors_1 = require("./wrapErrors");
10
10
  exports.default = (collection) => {
11
11
  const updateMany = async function (selectorArg, modifierArg, options = {}) {
12
+ await collection.connectionPromise;
12
13
  let modifier = modifierArg;
13
14
  const selector = (0, getSelector_1.default)(arguments);
14
15
  if (!modifier) {
@@ -9,6 +9,7 @@ const validateModifier_1 = __importDefault(require("./validateModifier"));
9
9
  const wrapErrors_1 = require("./wrapErrors");
10
10
  exports.default = (collection) => {
11
11
  const updateOne = async function (selectorArg, modifierArg, options = {}) {
12
+ await collection.connectionPromise;
12
13
  let modifier = modifierArg;
13
14
  const selector = (0, getSelector_1.default)(arguments);
14
15
  if (!modifier) {
@@ -9,6 +9,7 @@ const cleanModifier_1 = __importDefault(require("./cleanModifier"));
9
9
  const wrapErrors_1 = require("./wrapErrors");
10
10
  exports.default = (collection) => {
11
11
  const upsert = async function (selectorArg, modifierArg, options = {}) {
12
+ await collection.connectionPromise;
12
13
  let modifier = modifierArg;
13
14
  let selector = (0, getSelector_1.default)(arguments);
14
15
  modifier.$setOnInsert = { ...modifier.$setOnInsert, _id: collection.generateId() };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-js/mongodb",
3
- "version": "3.2.18",
3
+ "version": "3.2.20",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "files": [
@@ -17,7 +17,7 @@
17
17
  "upgrade-interactive": "yarn upgrade-interactive"
18
18
  },
19
19
  "dependencies": {
20
- "@orion-js/env": "^3.2.0",
20
+ "@orion-js/env": "^3.2.19",
21
21
  "@orion-js/helpers": "^3.2.0",
22
22
  "@orion-js/models": "^3.2.18",
23
23
  "@orion-js/resolvers": "^3.2.18",
@@ -40,5 +40,5 @@
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "95db28fdf82bca1f23a07ea3a0d8f1218b7c1373"
43
+ "gitHead": "4c4e24615699c336f041a4ff832ffb591e4a0537"
44
44
  }