@tomsd/mongodbclient 2.7.3 → 2.7.4

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.
@@ -28,7 +28,7 @@ export declare class MClient {
28
28
  read(condition?: any, opt?: any): Promise<unknown>;
29
29
  distinct(key: string, condition?: any): Promise<unknown>;
30
30
  remove(condition: any): Promise<unknown>;
31
- stats(): Promise<unknown>;
31
+ stats(): Promise<any>;
32
32
  count(condition?: any): Promise<number>;
33
33
  insertMany(items: any[]): Promise<unknown>;
34
34
  dbStats(): Promise<any>;
@@ -137,20 +137,17 @@ class MClient {
137
137
  });
138
138
  }
139
139
  stats() {
140
- const that = this;
141
- return new Promise(function (resolve, reject) {
142
- that.getConnected()
143
- .then(function (conn) {
144
- conn.collection.stats()
145
- .then(function (r) {
146
- conn.client.close();
147
- resolve(r);
148
- })
149
- .catch(function (e) {
150
- conn.client.close();
151
- reject(e);
152
- });
153
- }, reject);
140
+ return __awaiter(this, void 0, void 0, function* () {
141
+ const connection = yield this.getConnected();
142
+ try {
143
+ return yield connection.collection.stats();
144
+ }
145
+ catch (e) {
146
+ throw e;
147
+ }
148
+ finally {
149
+ connection.client.close();
150
+ }
154
151
  });
155
152
  }
156
153
  count(condition = {}) {
@@ -28,7 +28,7 @@ export declare class MClient {
28
28
  read(condition?: any, opt?: any): Promise<unknown>;
29
29
  distinct(key: string, condition?: any): Promise<unknown>;
30
30
  remove(condition: any): Promise<unknown>;
31
- stats(): Promise<unknown>;
31
+ stats(): Promise<any>;
32
32
  count(condition?: any): Promise<number>;
33
33
  insertMany(items: any[]): Promise<unknown>;
34
34
  dbStats(): Promise<any>;
@@ -133,20 +133,17 @@ export class MClient {
133
133
  });
134
134
  }
135
135
  stats() {
136
- const that = this;
137
- return new Promise(function (resolve, reject) {
138
- that.getConnected()
139
- .then(function (conn) {
140
- conn.collection.stats()
141
- .then(function (r) {
142
- conn.client.close();
143
- resolve(r);
144
- })
145
- .catch(function (e) {
146
- conn.client.close();
147
- reject(e);
148
- });
149
- }, reject);
136
+ return __awaiter(this, void 0, void 0, function* () {
137
+ const connection = yield this.getConnected();
138
+ try {
139
+ return yield connection.collection.stats();
140
+ }
141
+ catch (e) {
142
+ throw e;
143
+ }
144
+ finally {
145
+ connection.client.close();
146
+ }
150
147
  });
151
148
  }
152
149
  count(condition = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomsd/mongodbclient",
3
- "version": "2.7.3",
3
+ "version": "2.7.4",
4
4
  "description": "",
5
5
  "main": "dist/cjs/mongodbclient.js",
6
6
  "module": "dist/esm/mongodbclient.js",