mongodb-ops 0.9.1 → 0.9.3

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/mongodb-ops.js +4 -15
  2. package/package.json +1 -2
@@ -1,8 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const MongoClient = require('mongodb').MongoClient;
4
- const ObjectID = require('mongodb').ObjectID;
5
- const DEFAULT_POOLSIZE = 5;
4
+ const ObjectID = require('mongodb').ObjectId;
6
5
 
7
6
  class MongoDBOps {
8
7
  /**
@@ -36,10 +35,9 @@ class MongoDBOps {
36
35
  * Static method - Get DB client - It supports multiple db client with different connection string. Active db client will be reused for better performance
37
36
  *
38
37
  * @param {string} connString Database connection string
39
- * @param {number} [poolSize] Database client pool size
40
38
  * @returns {promise} Promise with db client
41
39
  */
42
- static async getDbClient(connString, poolSize = DEFAULT_POOLSIZE) {
40
+ static async getDbClient(connString) {
43
41
  if (!connString) { throw new Error("missing-connection-string"); }
44
42
 
45
43
  if (!Array.isArray(MongoDBOps.dbClientList)) { MongoDBOps.dbClientList = []; }
@@ -47,23 +45,14 @@ class MongoDBOps {
47
45
  for (let item of MongoDBOps.dbClientList) {
48
46
  if (item.s.url === connString) {
49
47
  if (item.topology.s.state !== "connected") {
50
- item = await MongoClient.connect(connString, {
51
- poolSize: poolSize !== DEFAULT_POOLSIZE ? poolSize : MongoDBOps.poolSize || DEFAULT_POOLSIZE,
52
- useNewUrlParser: true,
53
- useUnifiedTopology: true,
54
- });
48
+ item = await MongoClient.connect(connString);
55
49
  }
56
50
 
57
51
  return Promise.resolve(item);
58
52
  }
59
53
  }
60
54
 
61
- const newDbClient = await MongoClient.connect(connString, {
62
- poolSize: poolSize !== DEFAULT_POOLSIZE ? poolSize : MongoDBOps.poolSize || DEFAULT_POOLSIZE,
63
- useNewUrlParser: true,
64
- useUnifiedTopology: true,
65
- });
66
-
55
+ const newDbClient = await MongoClient.connect(connString);
67
56
  MongoDBOps.dbClientList.push(newDbClient);
68
57
 
69
58
  return Promise.resolve(newDbClient);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mongodb-ops",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "description": "Read and write ops for MongoDB",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -26,7 +26,6 @@
26
26
  "lib": "lib"
27
27
  },
28
28
  "devDependencies": {
29
- "babel-eslint": "^10.1.0",
30
29
  "eslint": "^8.34.0"
31
30
  }
32
31
  }