@tomsd/mongodbclient 2.7.6 → 2.7.9
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.
|
@@ -26,11 +26,11 @@ export declare class MClient {
|
|
|
26
26
|
protected getConnected(): Promise<any>;
|
|
27
27
|
upsert(pobj: any): Promise<any>;
|
|
28
28
|
read(condition?: any, opt?: any): Promise<any>;
|
|
29
|
-
distinct(key: string, condition?: any): Promise<
|
|
30
|
-
remove(condition: any): Promise<
|
|
29
|
+
distinct(key: string, condition?: any): Promise<any>;
|
|
30
|
+
remove(condition: any): Promise<any>;
|
|
31
31
|
stats(): Promise<any>;
|
|
32
32
|
count(condition?: any): Promise<number>;
|
|
33
|
-
insertMany(items: any[]): Promise<
|
|
33
|
+
insertMany(items: any[]): Promise<any>;
|
|
34
34
|
dbStats(): Promise<any>;
|
|
35
35
|
getCollections(): Promise<any>;
|
|
36
36
|
}
|
|
@@ -99,37 +99,31 @@ class MClient {
|
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
distinct(key, condition = {}) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
reject(e);
|
|
114
|
-
});
|
|
115
|
-
});
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
const connection = yield this.getConnected();
|
|
104
|
+
try {
|
|
105
|
+
return yield connection.collection.distinct(key, condition);
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
throw e;
|
|
109
|
+
}
|
|
110
|
+
finally {
|
|
111
|
+
connection.client.close();
|
|
112
|
+
}
|
|
116
113
|
});
|
|
117
114
|
}
|
|
118
115
|
remove(condition) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
reject(e);
|
|
131
|
-
});
|
|
132
|
-
}, reject);
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
const connection = yield this.getConnected();
|
|
118
|
+
try {
|
|
119
|
+
return yield connection.collection.deleteMany(condition, { writeConcern: { w: 1 } });
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
throw e;
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
connection.client.close();
|
|
126
|
+
}
|
|
133
127
|
});
|
|
134
128
|
}
|
|
135
129
|
stats() {
|
|
@@ -161,23 +155,19 @@ class MClient {
|
|
|
161
155
|
});
|
|
162
156
|
}
|
|
163
157
|
insertMany(items) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
conn.client.close();
|
|
178
|
-
reject(e);
|
|
179
|
-
});
|
|
180
|
-
}, reject);
|
|
158
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
const connection = yield this.getConnected();
|
|
160
|
+
const savingItems = items.map(item => (Object.assign({ _id: uuid_1.v4() }, item)));
|
|
161
|
+
try {
|
|
162
|
+
return yield connection.collection
|
|
163
|
+
.insertMany(savingItems, { writeConcern: { w: 1 } });
|
|
164
|
+
}
|
|
165
|
+
catch (e) {
|
|
166
|
+
throw e;
|
|
167
|
+
}
|
|
168
|
+
finally {
|
|
169
|
+
connection.client.close();
|
|
170
|
+
}
|
|
181
171
|
});
|
|
182
172
|
}
|
|
183
173
|
dbStats() {
|
|
@@ -26,11 +26,11 @@ export declare class MClient {
|
|
|
26
26
|
protected getConnected(): Promise<any>;
|
|
27
27
|
upsert(pobj: any): Promise<any>;
|
|
28
28
|
read(condition?: any, opt?: any): Promise<any>;
|
|
29
|
-
distinct(key: string, condition?: any): Promise<
|
|
30
|
-
remove(condition: any): Promise<
|
|
29
|
+
distinct(key: string, condition?: any): Promise<any>;
|
|
30
|
+
remove(condition: any): Promise<any>;
|
|
31
31
|
stats(): Promise<any>;
|
|
32
32
|
count(condition?: any): Promise<number>;
|
|
33
|
-
insertMany(items: any[]): Promise<
|
|
33
|
+
insertMany(items: any[]): Promise<any>;
|
|
34
34
|
dbStats(): Promise<any>;
|
|
35
35
|
getCollections(): Promise<any>;
|
|
36
36
|
}
|
|
@@ -95,37 +95,31 @@ export class MClient {
|
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
distinct(key, condition = {}) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
reject(e);
|
|
110
|
-
});
|
|
111
|
-
});
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const connection = yield this.getConnected();
|
|
100
|
+
try {
|
|
101
|
+
return yield connection.collection.distinct(key, condition);
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
throw e;
|
|
105
|
+
}
|
|
106
|
+
finally {
|
|
107
|
+
connection.client.close();
|
|
108
|
+
}
|
|
112
109
|
});
|
|
113
110
|
}
|
|
114
111
|
remove(condition) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
reject(e);
|
|
127
|
-
});
|
|
128
|
-
}, reject);
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
const connection = yield this.getConnected();
|
|
114
|
+
try {
|
|
115
|
+
return yield connection.collection.deleteMany(condition, { writeConcern: { w: 1 } });
|
|
116
|
+
}
|
|
117
|
+
catch (e) {
|
|
118
|
+
throw e;
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
connection.client.close();
|
|
122
|
+
}
|
|
129
123
|
});
|
|
130
124
|
}
|
|
131
125
|
stats() {
|
|
@@ -157,23 +151,19 @@ export class MClient {
|
|
|
157
151
|
});
|
|
158
152
|
}
|
|
159
153
|
insertMany(items) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
conn.client.close();
|
|
174
|
-
reject(e);
|
|
175
|
-
});
|
|
176
|
-
}, reject);
|
|
154
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
const connection = yield this.getConnected();
|
|
156
|
+
const savingItems = items.map(item => (Object.assign({ _id: uuidv4() }, item)));
|
|
157
|
+
try {
|
|
158
|
+
return yield connection.collection
|
|
159
|
+
.insertMany(savingItems, { writeConcern: { w: 1 } });
|
|
160
|
+
}
|
|
161
|
+
catch (e) {
|
|
162
|
+
throw e;
|
|
163
|
+
}
|
|
164
|
+
finally {
|
|
165
|
+
connection.client.close();
|
|
166
|
+
}
|
|
177
167
|
});
|
|
178
168
|
}
|
|
179
169
|
dbStats() {
|