@tomsd/mongodbclient 3.0.12 → 3.0.14

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/README.md CHANGED
@@ -7,7 +7,7 @@ See [mongodbclient.netlify.app](https://mongodbclient.netlify.app/) for details.
7
7
  ![NPM](https://img.shields.io/npm/l/@tomsd/mongodbclient)
8
8
  ![npms.io (quality)](https://img.shields.io/npms-io/quality-score/@tomsd/mongodbclient)
9
9
  ![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/npm/@tomsd/mongodbclient)
10
- ![Maintenance](https://img.shields.io/maintenance/yes/2023)
10
+ ![Maintenance](https://img.shields.io/maintenance/yes/2024)
11
11
  ![depends on mongodb@4](https://img.shields.io/badge/depends%20on-mongodb@4-informational)
12
12
 
13
13
  ## Installation
@@ -3,7 +3,7 @@
3
3
  * (c) 2020 tom
4
4
  * License: MIT
5
5
  */
6
- import { Db, Collection, CollStats, DeleteResult, Document, InsertManyResult, UpdateResult, WithId } from "mongodb";
6
+ import type { Db, Collection, CollStats, DeleteResult, Document, InsertManyResult, UpdateResult, WithId } from "mongodb";
7
7
  declare const MongoClient: any;
8
8
  export declare class MongoConnection {
9
9
  private readonly _client;
@@ -52,6 +52,7 @@ export class MClient {
52
52
  return client.connect().then((client) => {
53
53
  const db = client.db(this.m_db);
54
54
  const collection = db.collection(this.m_collection);
55
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
55
56
  return new MongoConnection(client, db, collection);
56
57
  });
57
58
  });
@@ -68,10 +69,11 @@ export class MClient {
68
69
  }
69
70
  });
70
71
  }
71
- read(condition = {}, opt) {
72
- return __awaiter(this, void 0, void 0, function* () {
72
+ read() {
73
+ return __awaiter(this, arguments, void 0, function* (condition = {}, opt) {
73
74
  const connection = yield this.getConnected();
74
75
  try {
76
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
75
77
  return yield connection.collection.find(condition, opt).toArray();
76
78
  }
77
79
  finally {
@@ -79,11 +81,14 @@ export class MClient {
79
81
  }
80
82
  });
81
83
  }
82
- distinct(key, condition = {}) {
83
- return __awaiter(this, void 0, void 0, function* () {
84
+ distinct(key_1) {
85
+ return __awaiter(this, arguments, void 0, function* (key, condition = {}) {
84
86
  const connection = yield this.getConnected();
85
87
  try {
86
- return (yield connection.collection.distinct(key, condition));
88
+ // eslint-disable-next-line
89
+ return (yield connection.collection.distinct(key,
90
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
91
+ condition));
87
92
  }
88
93
  finally {
89
94
  connection.client.close();
@@ -94,6 +99,7 @@ export class MClient {
94
99
  return __awaiter(this, void 0, void 0, function* () {
95
100
  const connection = yield this.getConnected();
96
101
  try {
102
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
97
103
  return yield connection.collection.deleteMany(condition, {
98
104
  writeConcern: { w: 1 },
99
105
  });
@@ -114,11 +120,14 @@ export class MClient {
114
120
  }
115
121
  });
116
122
  }
117
- count(condition = {}) {
118
- return __awaiter(this, void 0, void 0, function* () {
123
+ count() {
124
+ return __awaiter(this, arguments, void 0, function* (condition = {}) {
119
125
  const connection = yield this.getConnected();
120
126
  try {
121
- return (yield connection.collection.countDocuments(condition));
127
+ // eslint-disable-next-line
128
+ return (yield connection.collection.countDocuments(
129
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
130
+ condition));
122
131
  }
123
132
  finally {
124
133
  connection.client.close();
@@ -130,6 +139,7 @@ export class MClient {
130
139
  const connection = yield this.getConnected();
131
140
  const savingItems = items.map((item) => (Object.assign({ _id: uuidv4() }, item)));
132
141
  try {
142
+ // eslint-disable-next-line
133
143
  return yield connection.collection.insertMany(savingItems, {
134
144
  writeConcern: { w: 1 },
135
145
  });
@@ -0,0 +1,183 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/mongodbclient.ts
20
+ var mongodbclient_exports = {};
21
+ __export(mongodbclient_exports, {
22
+ MClient: () => MClient,
23
+ MongoConnection: () => MongoConnection,
24
+ default: () => mongodbclient_default
25
+ });
26
+ module.exports = __toCommonJS(mongodbclient_exports);
27
+ var import_uuid = require("uuid");
28
+ var MongoClient = require("mongodb").MongoClient;
29
+ var MongoConnection = class {
30
+ _client;
31
+ _db;
32
+ _collection;
33
+ constructor(client, db, collection) {
34
+ this._client = client;
35
+ this._db = db;
36
+ this._collection = collection;
37
+ }
38
+ get client() {
39
+ return this._client;
40
+ }
41
+ get db() {
42
+ return this._db;
43
+ }
44
+ get collection() {
45
+ return this._collection;
46
+ }
47
+ };
48
+ var MClient = class {
49
+ m_uri;
50
+ m_db;
51
+ m_collection;
52
+ constructor(uri, db, collection) {
53
+ this.m_uri = uri;
54
+ this.m_db = db;
55
+ this.m_collection = collection;
56
+ }
57
+ get uri() {
58
+ return this.m_uri;
59
+ }
60
+ get db() {
61
+ return this.m_db;
62
+ }
63
+ get collection() {
64
+ return this.m_collection;
65
+ }
66
+ async connect() {
67
+ return await this.getConnected();
68
+ }
69
+ async getConnected() {
70
+ const client = new MongoClient(this.m_uri, { useUnifiedTopology: true });
71
+ return client.connect().then((client2) => {
72
+ const db = client2.db(this.m_db);
73
+ const collection = db.collection(this.m_collection);
74
+ return new MongoConnection(client2, db, collection);
75
+ });
76
+ }
77
+ async upsert(pobj) {
78
+ const savingObj = {
79
+ _id: (0, import_uuid.v4)(),
80
+ ...pobj
81
+ };
82
+ const connection = await this.getConnected();
83
+ try {
84
+ return await connection.collection.updateOne(
85
+ { _id: savingObj._id },
86
+ { $set: savingObj },
87
+ { upsert: true, writeConcern: { w: 1 } }
88
+ );
89
+ } finally {
90
+ connection.client.close();
91
+ }
92
+ }
93
+ async read(condition = {}, opt) {
94
+ const connection = await this.getConnected();
95
+ try {
96
+ return await connection.collection.find(condition, opt).toArray();
97
+ } finally {
98
+ connection.client.close();
99
+ }
100
+ }
101
+ async distinct(key, condition = {}) {
102
+ const connection = await this.getConnected();
103
+ try {
104
+ return await connection.collection.distinct(
105
+ key,
106
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
107
+ condition
108
+ );
109
+ } finally {
110
+ connection.client.close();
111
+ }
112
+ }
113
+ async remove(condition) {
114
+ const connection = await this.getConnected();
115
+ try {
116
+ return await connection.collection.deleteMany(condition, {
117
+ writeConcern: { w: 1 }
118
+ });
119
+ } finally {
120
+ connection.client.close();
121
+ }
122
+ }
123
+ async stats() {
124
+ const connection = await this.getConnected();
125
+ try {
126
+ return await connection.collection.stats();
127
+ } finally {
128
+ connection.client.close();
129
+ }
130
+ }
131
+ async count(condition = {}) {
132
+ const connection = await this.getConnected();
133
+ try {
134
+ return await connection.collection.countDocuments(
135
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
136
+ condition
137
+ );
138
+ } finally {
139
+ connection.client.close();
140
+ }
141
+ }
142
+ async insertMany(items) {
143
+ const connection = await this.getConnected();
144
+ const savingItems = items.map((item) => ({
145
+ _id: (0, import_uuid.v4)(),
146
+ ...item
147
+ }));
148
+ try {
149
+ return await connection.collection.insertMany(savingItems, {
150
+ writeConcern: { w: 1 }
151
+ });
152
+ } finally {
153
+ connection.client.close();
154
+ }
155
+ }
156
+ async dbStats() {
157
+ const connection = await this.getConnected();
158
+ try {
159
+ return await connection.db.stats();
160
+ } finally {
161
+ connection.client.close();
162
+ }
163
+ }
164
+ async getCollections() {
165
+ const connection = await this.getConnected();
166
+ try {
167
+ return await connection.db.collections();
168
+ } finally {
169
+ connection.client.close();
170
+ }
171
+ }
172
+ };
173
+ var mongodbclient_default = MClient;
174
+ // Annotate the CommonJS export names for ESM import in node:
175
+ 0 && (module.exports = {
176
+ MClient,
177
+ MongoConnection
178
+ });
179
+ /*!
180
+ * @license mongodbclient
181
+ * (c) 2020 tom
182
+ * License: MIT
183
+ */
@@ -0,0 +1,166 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined")
5
+ return require.apply(this, arguments);
6
+ throw Error('Dynamic require of "' + x + '" is not supported');
7
+ });
8
+
9
+ // src/mongodbclient.ts
10
+ import { v4 as uuidv4 } from "uuid";
11
+ var MongoClient = __require("mongodb").MongoClient;
12
+ var MongoConnection = class {
13
+ _client;
14
+ _db;
15
+ _collection;
16
+ constructor(client, db, collection) {
17
+ this._client = client;
18
+ this._db = db;
19
+ this._collection = collection;
20
+ }
21
+ get client() {
22
+ return this._client;
23
+ }
24
+ get db() {
25
+ return this._db;
26
+ }
27
+ get collection() {
28
+ return this._collection;
29
+ }
30
+ };
31
+ var MClient = class {
32
+ m_uri;
33
+ m_db;
34
+ m_collection;
35
+ constructor(uri, db, collection) {
36
+ this.m_uri = uri;
37
+ this.m_db = db;
38
+ this.m_collection = collection;
39
+ }
40
+ get uri() {
41
+ return this.m_uri;
42
+ }
43
+ get db() {
44
+ return this.m_db;
45
+ }
46
+ get collection() {
47
+ return this.m_collection;
48
+ }
49
+ async connect() {
50
+ return await this.getConnected();
51
+ }
52
+ async getConnected() {
53
+ const client = new MongoClient(this.m_uri, { useUnifiedTopology: true });
54
+ return client.connect().then((client2) => {
55
+ const db = client2.db(this.m_db);
56
+ const collection = db.collection(this.m_collection);
57
+ return new MongoConnection(client2, db, collection);
58
+ });
59
+ }
60
+ async upsert(pobj) {
61
+ const savingObj = {
62
+ _id: uuidv4(),
63
+ ...pobj
64
+ };
65
+ const connection = await this.getConnected();
66
+ try {
67
+ return await connection.collection.updateOne(
68
+ { _id: savingObj._id },
69
+ { $set: savingObj },
70
+ { upsert: true, writeConcern: { w: 1 } }
71
+ );
72
+ } finally {
73
+ connection.client.close();
74
+ }
75
+ }
76
+ async read(condition = {}, opt) {
77
+ const connection = await this.getConnected();
78
+ try {
79
+ return await connection.collection.find(condition, opt).toArray();
80
+ } finally {
81
+ connection.client.close();
82
+ }
83
+ }
84
+ async distinct(key, condition = {}) {
85
+ const connection = await this.getConnected();
86
+ try {
87
+ return await connection.collection.distinct(
88
+ key,
89
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
90
+ condition
91
+ );
92
+ } finally {
93
+ connection.client.close();
94
+ }
95
+ }
96
+ async remove(condition) {
97
+ const connection = await this.getConnected();
98
+ try {
99
+ return await connection.collection.deleteMany(condition, {
100
+ writeConcern: { w: 1 }
101
+ });
102
+ } finally {
103
+ connection.client.close();
104
+ }
105
+ }
106
+ async stats() {
107
+ const connection = await this.getConnected();
108
+ try {
109
+ return await connection.collection.stats();
110
+ } finally {
111
+ connection.client.close();
112
+ }
113
+ }
114
+ async count(condition = {}) {
115
+ const connection = await this.getConnected();
116
+ try {
117
+ return await connection.collection.countDocuments(
118
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
119
+ condition
120
+ );
121
+ } finally {
122
+ connection.client.close();
123
+ }
124
+ }
125
+ async insertMany(items) {
126
+ const connection = await this.getConnected();
127
+ const savingItems = items.map((item) => ({
128
+ _id: uuidv4(),
129
+ ...item
130
+ }));
131
+ try {
132
+ return await connection.collection.insertMany(savingItems, {
133
+ writeConcern: { w: 1 }
134
+ });
135
+ } finally {
136
+ connection.client.close();
137
+ }
138
+ }
139
+ async dbStats() {
140
+ const connection = await this.getConnected();
141
+ try {
142
+ return await connection.db.stats();
143
+ } finally {
144
+ connection.client.close();
145
+ }
146
+ }
147
+ async getCollections() {
148
+ const connection = await this.getConnected();
149
+ try {
150
+ return await connection.db.collections();
151
+ } finally {
152
+ connection.client.close();
153
+ }
154
+ }
155
+ };
156
+ var mongodbclient_default = MClient;
157
+ export {
158
+ MClient,
159
+ MongoConnection,
160
+ mongodbclient_default as default
161
+ };
162
+ /*!
163
+ * @license mongodbclient
164
+ * (c) 2020 tom
165
+ * License: MIT
166
+ */
package/package.json CHANGED
@@ -1,22 +1,24 @@
1
1
  {
2
2
  "name": "@tomsd/mongodbclient",
3
- "version": "3.0.12",
3
+ "version": "3.0.14",
4
4
  "description": "It's a handy mongodb client for easy-use.",
5
- "main": "dist/cjs/mongodbclient.js",
6
- "module": "dist/esm/mongodbclient.js",
5
+ "main": "dist/mongodbclient.cjs.js",
6
+ "module": "dist/mongodbclient.esm.js",
7
7
  "types": "dist/esm/mongodbclient.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
8
11
  "scripts": {
9
- "build": "tsc --project tsconfig.cjs.json && tsc --project tsconfig.esm.json",
12
+ "build": "tsup && tsc --project tsconfig.esm.json",
10
13
  "format": "npm run format:src && npm run format:test",
11
14
  "format:document": "prettier --write docs/**/*.html",
12
15
  "format:src": "prettier --write src/**/*.ts",
13
- "format:test": "prettier --write test/**/*.ts",
14
- "lint:src": "eslint src/**/*.ts",
15
- "lint:test": "eslint test/**/*.ts",
16
- "prepare": "husky install",
16
+ "format:test": "prettier --write __test__/**/*.ts",
17
+ "lint:src": "ESLINT_USE_FLAT_CONFIG=false eslint src/**/*.ts",
18
+ "lint:test": "ESLINT_USE_FLAT_CONFIG=false eslint __test__/**/*.ts",
19
+ "prepare": "husky",
17
20
  "serve:doc": "mdbook --serve --directory docs",
18
- "test": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' mocha -r ts-node/register \"test/mclient.test.ts\" --timeout 30000",
19
- "test_with_dburi": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' mocha -r ts-node/register \"test/with_dburi.test.ts\" --timeout 30000"
21
+ "test": "vitest"
20
22
  },
21
23
  "lint-staged": {
22
24
  "docs/**/*.html": [
@@ -26,7 +28,7 @@
26
28
  "npm run lint:src",
27
29
  "npm run format:src"
28
30
  ],
29
- "test/**/*.ts": [
31
+ "__test__/**/*.ts": [
30
32
  "npm run lint:test",
31
33
  "npm run format:test"
32
34
  ]
@@ -41,29 +43,25 @@
41
43
  "url": "https://github.com/tomsdoo/mongodbclient"
42
44
  },
43
45
  "dependencies": {
44
- "mongodb": "^4.7.0",
45
- "uuid": "^8.3.2"
46
+ "mongodb": "4.7.0",
47
+ "uuid": "9.0.1"
46
48
  },
47
49
  "devDependencies": {
48
- "@tomsd/md-book": "^0.16.0",
49
- "@types/mocha": "^9.1.1",
50
- "@types/node": "^14.14.5",
51
- "@types/sinon": "^10.0.13",
52
- "@types/uuid": "^8.3.4",
53
- "@typescript-eslint/eslint-plugin": "^5.38.0",
54
- "dotenv": "^16.0.1",
55
- "eslint": "^8.24.0",
56
- "eslint-config-prettier": "^8.5.0",
57
- "eslint-config-standard-with-typescript": "^23.0.0",
58
- "eslint-plugin-import": "^2.26.0",
59
- "eslint-plugin-n": "^15.3.0",
60
- "eslint-plugin-promise": "^6.0.1",
61
- "husky": "^8.0.1",
62
- "lint-staged": "^13.0.3",
63
- "mocha": "^7.2.0",
64
- "prettier": "^2.7.1",
65
- "sinon": "^14.0.0",
66
- "ts-node": "^10.8.1",
67
- "typescript": "^4.8.3"
50
+ "@tomsd/md-book": "1.2.0",
51
+ "@types/node": "20.12.12",
52
+ "@types/uuid": "9.0.8",
53
+ "@typescript-eslint/eslint-plugin": "7.9.0",
54
+ "dotenv": "16.4.5",
55
+ "eslint": "8.57.0",
56
+ "eslint-config-prettier": "9.1.0",
57
+ "eslint-plugin-import": "2.29.1",
58
+ "eslint-plugin-n": "17.7.0",
59
+ "eslint-plugin-promise": "6.1.1",
60
+ "husky": "9.0.11",
61
+ "lint-staged": "15.2.2",
62
+ "prettier": "3.2.5",
63
+ "tsup": "8.0.2",
64
+ "typescript": "5.4.5",
65
+ "vitest": "1.6.0"
68
66
  }
69
67
  }
@@ -1,170 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.MClient = exports.MongoConnection = void 0;
13
- const uuid_1 = require("uuid");
14
- // eslint-disable-next-line @typescript-eslint/no-var-requires
15
- const MongoClient = require("mongodb").MongoClient;
16
- class MongoConnection {
17
- constructor(client, db, collection) {
18
- this._client = client;
19
- this._db = db;
20
- this._collection = collection;
21
- }
22
- get client() {
23
- return this._client;
24
- }
25
- get db() {
26
- return this._db;
27
- }
28
- get collection() {
29
- return this._collection;
30
- }
31
- }
32
- exports.MongoConnection = MongoConnection;
33
- class MClient {
34
- constructor(uri, db, collection) {
35
- this.m_uri = uri;
36
- this.m_db = db;
37
- this.m_collection = collection;
38
- }
39
- get uri() {
40
- return this.m_uri;
41
- }
42
- get db() {
43
- return this.m_db;
44
- }
45
- get collection() {
46
- return this.m_collection;
47
- }
48
- connect() {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- return yield this.getConnected();
51
- });
52
- }
53
- getConnected() {
54
- return __awaiter(this, void 0, void 0, function* () {
55
- const client = new MongoClient(this.m_uri, { useUnifiedTopology: true });
56
- return client.connect().then((client) => {
57
- const db = client.db(this.m_db);
58
- const collection = db.collection(this.m_collection);
59
- return new MongoConnection(client, db, collection);
60
- });
61
- });
62
- }
63
- upsert(pobj) {
64
- return __awaiter(this, void 0, void 0, function* () {
65
- const savingObj = Object.assign({ _id: (0, uuid_1.v4)() }, pobj);
66
- const connection = yield this.getConnected();
67
- try {
68
- return yield connection.collection.updateOne({ _id: savingObj._id }, { $set: savingObj }, { upsert: true, writeConcern: { w: 1 } });
69
- }
70
- finally {
71
- connection.client.close();
72
- }
73
- });
74
- }
75
- read(condition = {}, opt) {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- const connection = yield this.getConnected();
78
- try {
79
- return yield connection.collection.find(condition, opt).toArray();
80
- }
81
- finally {
82
- connection.client.close();
83
- }
84
- });
85
- }
86
- distinct(key, condition = {}) {
87
- return __awaiter(this, void 0, void 0, function* () {
88
- const connection = yield this.getConnected();
89
- try {
90
- return (yield connection.collection.distinct(key, condition));
91
- }
92
- finally {
93
- connection.client.close();
94
- }
95
- });
96
- }
97
- remove(condition) {
98
- return __awaiter(this, void 0, void 0, function* () {
99
- const connection = yield this.getConnected();
100
- try {
101
- return yield connection.collection.deleteMany(condition, {
102
- writeConcern: { w: 1 },
103
- });
104
- }
105
- finally {
106
- connection.client.close();
107
- }
108
- });
109
- }
110
- stats() {
111
- return __awaiter(this, void 0, void 0, function* () {
112
- const connection = yield this.getConnected();
113
- try {
114
- return yield connection.collection.stats();
115
- }
116
- finally {
117
- connection.client.close();
118
- }
119
- });
120
- }
121
- count(condition = {}) {
122
- return __awaiter(this, void 0, void 0, function* () {
123
- const connection = yield this.getConnected();
124
- try {
125
- return (yield connection.collection.countDocuments(condition));
126
- }
127
- finally {
128
- connection.client.close();
129
- }
130
- });
131
- }
132
- insertMany(items) {
133
- return __awaiter(this, void 0, void 0, function* () {
134
- const connection = yield this.getConnected();
135
- const savingItems = items.map((item) => (Object.assign({ _id: (0, uuid_1.v4)() }, item)));
136
- try {
137
- return yield connection.collection.insertMany(savingItems, {
138
- writeConcern: { w: 1 },
139
- });
140
- }
141
- finally {
142
- connection.client.close();
143
- }
144
- });
145
- }
146
- dbStats() {
147
- return __awaiter(this, void 0, void 0, function* () {
148
- const connection = yield this.getConnected();
149
- try {
150
- return yield connection.db.stats();
151
- }
152
- finally {
153
- connection.client.close();
154
- }
155
- });
156
- }
157
- getCollections() {
158
- return __awaiter(this, void 0, void 0, function* () {
159
- const connection = yield this.getConnected();
160
- try {
161
- return yield connection.db.collections();
162
- }
163
- finally {
164
- connection.client.close();
165
- }
166
- });
167
- }
168
- }
169
- exports.MClient = MClient;
170
- exports.default = MClient;