mongodb-ops 0.10.1 → 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.
- package/lib/mongodb-ops.js +21 -0
- package/package.json +1 -1
package/lib/mongodb-ops.js
CHANGED
|
@@ -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/}
|