@tomsd/mongodbclient 2.7.4 → 2.7.7
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,9 +24,9 @@ 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<
|
|
29
|
-
distinct(key: string, condition?: any): Promise<
|
|
27
|
+
upsert(pobj: any): Promise<any>;
|
|
28
|
+
read(condition?: any, opt?: any): Promise<any>;
|
|
29
|
+
distinct(key: string, condition?: any): Promise<any>;
|
|
30
30
|
remove(condition: any): Promise<unknown>;
|
|
31
31
|
stats(): Promise<any>;
|
|
32
32
|
count(condition?: any): Promise<number>;
|
|
@@ -67,56 +67,49 @@ 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 = {}) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
reject(e);
|
|
118
|
-
});
|
|
119
|
-
});
|
|
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
|
+
}
|
|
120
113
|
});
|
|
121
114
|
}
|
|
122
115
|
remove(condition) {
|
|
@@ -24,9 +24,9 @@ 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<
|
|
29
|
-
distinct(key: string, condition?: any): Promise<
|
|
27
|
+
upsert(pobj: any): Promise<any>;
|
|
28
|
+
read(condition?: any, opt?: any): Promise<any>;
|
|
29
|
+
distinct(key: string, condition?: any): Promise<any>;
|
|
30
30
|
remove(condition: any): Promise<unknown>;
|
|
31
31
|
stats(): Promise<any>;
|
|
32
32
|
count(condition?: any): Promise<number>;
|
|
@@ -63,56 +63,49 @@ 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 = {}) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
reject(e);
|
|
114
|
-
});
|
|
115
|
-
});
|
|
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
|
+
}
|
|
116
109
|
});
|
|
117
110
|
}
|
|
118
111
|
remove(condition) {
|