@tomsd/mongodbclient 2.7.4 → 2.7.5
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,7 +24,7 @@ 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<
|
|
27
|
+
upsert(pobj: any): Promise<any>;
|
|
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>;
|
|
@@ -67,21 +67,18 @@ 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) {
|
|
@@ -24,7 +24,7 @@ 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<
|
|
27
|
+
upsert(pobj: any): Promise<any>;
|
|
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>;
|
|
@@ -63,21 +63,18 @@ 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) {
|