@tomsd/mongodbclient 2.7.3 → 2.7.6
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.
|
@@ -24,11 +24,11 @@ export declare class MClient {
|
|
|
24
24
|
get collection(): string;
|
|
25
25
|
connect(): Promise<any>;
|
|
26
26
|
protected getConnected(): Promise<any>;
|
|
27
|
-
upsert(pobj: any): Promise<
|
|
28
|
-
read(condition?: any, opt?: any): Promise<
|
|
27
|
+
upsert(pobj: any): Promise<any>;
|
|
28
|
+
read(condition?: any, opt?: any): Promise<any>;
|
|
29
29
|
distinct(key: string, condition?: any): Promise<unknown>;
|
|
30
30
|
remove(condition: any): Promise<unknown>;
|
|
31
|
-
stats(): Promise<
|
|
31
|
+
stats(): Promise<any>;
|
|
32
32
|
count(condition?: any): Promise<number>;
|
|
33
33
|
insertMany(items: any[]): Promise<unknown>;
|
|
34
34
|
dbStats(): Promise<any>;
|
|
@@ -67,39 +67,35 @@ class MClient {
|
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
upsert(pobj) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
reject(e);
|
|
83
|
-
});
|
|
84
|
-
}, reject);
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
const savingObj = Object.assign({ _id: uuid_1.v4() }, pobj);
|
|
72
|
+
const connection = yield this.getConnected();
|
|
73
|
+
try {
|
|
74
|
+
return yield connection.collection.updateOne({ _id: savingObj._id }, { $set: savingObj }, { upsert: true, writeConcern: { w: 1 } });
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
throw e;
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
connection.client.close();
|
|
81
|
+
}
|
|
85
82
|
});
|
|
86
83
|
}
|
|
87
84
|
read(condition = {}, opt) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
.
|
|
94
|
-
.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
});
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
const connection = yield this.getConnected();
|
|
87
|
+
try {
|
|
88
|
+
return yield connection
|
|
89
|
+
.collection
|
|
90
|
+
.find(condition, opt)
|
|
91
|
+
.toArray();
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
throw e;
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
connection.client.close();
|
|
98
|
+
}
|
|
103
99
|
});
|
|
104
100
|
}
|
|
105
101
|
distinct(key, condition = {}) {
|
|
@@ -137,20 +133,17 @@ class MClient {
|
|
|
137
133
|
});
|
|
138
134
|
}
|
|
139
135
|
stats() {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
reject(e);
|
|
152
|
-
});
|
|
153
|
-
}, 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
|
+
}
|
|
154
147
|
});
|
|
155
148
|
}
|
|
156
149
|
count(condition = {}) {
|
|
@@ -24,11 +24,11 @@ export declare class MClient {
|
|
|
24
24
|
get collection(): string;
|
|
25
25
|
connect(): Promise<any>;
|
|
26
26
|
protected getConnected(): Promise<any>;
|
|
27
|
-
upsert(pobj: any): Promise<
|
|
28
|
-
read(condition?: any, opt?: any): Promise<
|
|
27
|
+
upsert(pobj: any): Promise<any>;
|
|
28
|
+
read(condition?: any, opt?: any): Promise<any>;
|
|
29
29
|
distinct(key: string, condition?: any): Promise<unknown>;
|
|
30
30
|
remove(condition: any): Promise<unknown>;
|
|
31
|
-
stats(): Promise<
|
|
31
|
+
stats(): Promise<any>;
|
|
32
32
|
count(condition?: any): Promise<number>;
|
|
33
33
|
insertMany(items: any[]): Promise<unknown>;
|
|
34
34
|
dbStats(): Promise<any>;
|
|
@@ -63,39 +63,35 @@ export class MClient {
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
upsert(pobj) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
reject(e);
|
|
79
|
-
});
|
|
80
|
-
}, reject);
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const savingObj = Object.assign({ _id: uuidv4() }, pobj);
|
|
68
|
+
const connection = yield this.getConnected();
|
|
69
|
+
try {
|
|
70
|
+
return yield connection.collection.updateOne({ _id: savingObj._id }, { $set: savingObj }, { upsert: true, writeConcern: { w: 1 } });
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
throw e;
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
connection.client.close();
|
|
77
|
+
}
|
|
81
78
|
});
|
|
82
79
|
}
|
|
83
80
|
read(condition = {}, opt) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
.
|
|
90
|
-
.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
});
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const connection = yield this.getConnected();
|
|
83
|
+
try {
|
|
84
|
+
return yield connection
|
|
85
|
+
.collection
|
|
86
|
+
.find(condition, opt)
|
|
87
|
+
.toArray();
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
throw e;
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
connection.client.close();
|
|
94
|
+
}
|
|
99
95
|
});
|
|
100
96
|
}
|
|
101
97
|
distinct(key, condition = {}) {
|
|
@@ -133,20 +129,17 @@ export class MClient {
|
|
|
133
129
|
});
|
|
134
130
|
}
|
|
135
131
|
stats() {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
reject(e);
|
|
148
|
-
});
|
|
149
|
-
}, reject);
|
|
132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
const connection = yield this.getConnected();
|
|
134
|
+
try {
|
|
135
|
+
return yield connection.collection.stats();
|
|
136
|
+
}
|
|
137
|
+
catch (e) {
|
|
138
|
+
throw e;
|
|
139
|
+
}
|
|
140
|
+
finally {
|
|
141
|
+
connection.client.close();
|
|
142
|
+
}
|
|
150
143
|
});
|
|
151
144
|
}
|
|
152
145
|
count(condition = {}) {
|