@tomsd/mongodbclient 2.6.0 → 2.7.2
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/dist/cjs/mongodbclient.d.ts +2 -2
- package/dist/cjs/mongodbclient.js +42 -42
- package/dist/esm/mongodbclient.d.ts +2 -2
- package/dist/esm/mongodbclient.js +42 -42
- package/package.json +1 -1
- package/test/test.ts +5 -0
|
@@ -31,7 +31,7 @@ export declare class MClient {
|
|
|
31
31
|
stats(): Promise<unknown>;
|
|
32
32
|
count(condition?: any): Promise<number>;
|
|
33
33
|
insertMany(items: any[]): Promise<unknown>;
|
|
34
|
-
dbStats(): Promise<
|
|
35
|
-
getCollections(): Promise<any
|
|
34
|
+
dbStats(): Promise<any>;
|
|
35
|
+
getCollections(): Promise<any>;
|
|
36
36
|
}
|
|
37
37
|
export default MClient;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
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
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.MClient = exports.MongoConnection = void 0;
|
|
4
13
|
/*!
|
|
@@ -148,20 +157,17 @@ class MClient {
|
|
|
148
157
|
});
|
|
149
158
|
}
|
|
150
159
|
count(condition = {}) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
reject(e);
|
|
163
|
-
});
|
|
164
|
-
}, reject);
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
const connection = yield this.getConnected();
|
|
162
|
+
try {
|
|
163
|
+
return yield connection.collection.countDocuments(condition);
|
|
164
|
+
}
|
|
165
|
+
catch (e) {
|
|
166
|
+
throw e;
|
|
167
|
+
}
|
|
168
|
+
finally {
|
|
169
|
+
connection.client.close();
|
|
170
|
+
}
|
|
165
171
|
});
|
|
166
172
|
}
|
|
167
173
|
insertMany(items) {
|
|
@@ -185,37 +191,31 @@ class MClient {
|
|
|
185
191
|
});
|
|
186
192
|
}
|
|
187
193
|
dbStats() {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
.
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
reject(e);
|
|
200
|
-
});
|
|
201
|
-
}, reject);
|
|
194
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
195
|
+
const connection = yield this.getConnected();
|
|
196
|
+
try {
|
|
197
|
+
return yield connection.db.stats();
|
|
198
|
+
}
|
|
199
|
+
catch (e) {
|
|
200
|
+
throw e;
|
|
201
|
+
}
|
|
202
|
+
finally {
|
|
203
|
+
connection.client.close();
|
|
204
|
+
}
|
|
202
205
|
});
|
|
203
206
|
}
|
|
204
207
|
getCollections() {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
.
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
reject(e);
|
|
217
|
-
});
|
|
218
|
-
}, reject);
|
|
208
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
209
|
+
const connection = yield this.getConnected();
|
|
210
|
+
try {
|
|
211
|
+
return yield connection.db.collections();
|
|
212
|
+
}
|
|
213
|
+
catch (e) {
|
|
214
|
+
throw e;
|
|
215
|
+
}
|
|
216
|
+
finally {
|
|
217
|
+
connection.client.close();
|
|
218
|
+
}
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
221
|
}
|
|
@@ -31,7 +31,7 @@ export declare class MClient {
|
|
|
31
31
|
stats(): Promise<unknown>;
|
|
32
32
|
count(condition?: any): Promise<number>;
|
|
33
33
|
insertMany(items: any[]): Promise<unknown>;
|
|
34
|
-
dbStats(): Promise<
|
|
35
|
-
getCollections(): Promise<any
|
|
34
|
+
dbStats(): Promise<any>;
|
|
35
|
+
getCollections(): Promise<any>;
|
|
36
36
|
}
|
|
37
37
|
export default MClient;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
/*!
|
|
2
11
|
* @license mongodbclient
|
|
3
12
|
* (c) 2020 tom
|
|
@@ -144,20 +153,17 @@ export class MClient {
|
|
|
144
153
|
});
|
|
145
154
|
}
|
|
146
155
|
count(condition = {}) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
reject(e);
|
|
159
|
-
});
|
|
160
|
-
}, reject);
|
|
156
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
+
const connection = yield this.getConnected();
|
|
158
|
+
try {
|
|
159
|
+
return yield connection.collection.countDocuments(condition);
|
|
160
|
+
}
|
|
161
|
+
catch (e) {
|
|
162
|
+
throw e;
|
|
163
|
+
}
|
|
164
|
+
finally {
|
|
165
|
+
connection.client.close();
|
|
166
|
+
}
|
|
161
167
|
});
|
|
162
168
|
}
|
|
163
169
|
insertMany(items) {
|
|
@@ -181,37 +187,31 @@ export class MClient {
|
|
|
181
187
|
});
|
|
182
188
|
}
|
|
183
189
|
dbStats() {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
.
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
reject(e);
|
|
196
|
-
});
|
|
197
|
-
}, reject);
|
|
190
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
+
const connection = yield this.getConnected();
|
|
192
|
+
try {
|
|
193
|
+
return yield connection.db.stats();
|
|
194
|
+
}
|
|
195
|
+
catch (e) {
|
|
196
|
+
throw e;
|
|
197
|
+
}
|
|
198
|
+
finally {
|
|
199
|
+
connection.client.close();
|
|
200
|
+
}
|
|
198
201
|
});
|
|
199
202
|
}
|
|
200
203
|
getCollections() {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
reject(e);
|
|
213
|
-
});
|
|
214
|
-
}, reject);
|
|
204
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
205
|
+
const connection = yield this.getConnected();
|
|
206
|
+
try {
|
|
207
|
+
return yield connection.db.collections();
|
|
208
|
+
}
|
|
209
|
+
catch (e) {
|
|
210
|
+
throw e;
|
|
211
|
+
}
|
|
212
|
+
finally {
|
|
213
|
+
connection.client.close();
|
|
214
|
+
}
|
|
215
215
|
});
|
|
216
216
|
}
|
|
217
217
|
}
|
package/package.json
CHANGED
package/test/test.ts
CHANGED
|
@@ -47,6 +47,11 @@ describe("MClient", () => {
|
|
|
47
47
|
assert.equal(names.length, 4);
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
+
it("dbStats()", async () => {
|
|
51
|
+
const { storageSize } = (await mdbc.dbStats()) as { storageSize: number };
|
|
52
|
+
assert(storageSize > 0);
|
|
53
|
+
});
|
|
54
|
+
|
|
50
55
|
it("stats()", async () => {
|
|
51
56
|
const { storageSize } = (await mdbc.stats()) as { storageSize: number };
|
|
52
57
|
assert(storageSize > 0);
|