mongodb-ops 0.10.0 → 0.11.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/mongodb-ops.js +21 -0
  2. package/package.json +2 -5
@@ -79,6 +79,27 @@ class MongoDBOps {
79
79
  return Promise.resolve(await MongoDBOps.closeDBConn());
80
80
  }
81
81
 
82
+ /**
83
+ * Static method - Get estimated document count of a collection
84
+ *
85
+ * @param {string} collectionName Collection Name
86
+ * @param {string} connString Database connection string
87
+ */
88
+ static async getCollectionCount(collectionName, connString) {
89
+ const db = (await MongoDBOps.getDbClient(connString)).db();
90
+ return Promise.resolve(await db.collection(collectionName).estimatedDocumentCount());
91
+ }
92
+
93
+ /**
94
+ * Instance method - Get estimated document count of a collection
95
+ *
96
+ * @param {string} collectionName Collection Name
97
+ * @param {string} connString Database connection string
98
+ */
99
+ async getCollectionCount(collectionName) {
100
+ return Promise.resolve(await MongoDBOps.getData(collectionName, this.connString));
101
+ }
102
+
82
103
  /**
83
104
  * Static method - Get documents from MongoDB
84
105
  * {@link https://docs.mongodb.com/manual/reference/method/db.collection.find/}
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "mongodb-ops",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Read and write ops for MongoDB",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
8
8
  },
9
9
  "dependencies": {
10
- "mongodb": "^5.0.1"
10
+ "mongodb": "^6.8.0"
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
@@ -24,8 +24,5 @@
24
24
  "homepage": "https://github.com/CompAndSave/mongodb-ops#readme",
25
25
  "directories": {
26
26
  "lib": "lib"
27
- },
28
- "devDependencies": {
29
- "eslint": "^8.34.0"
30
27
  }
31
28
  }