@optimiser/common 1.0.392 → 1.0.393
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/lib/utility.js +46 -28
- package/package.json +1 -1
package/dist/lib/utility.js
CHANGED
|
@@ -793,14 +793,14 @@ function DeleteFieldInOtherCollection(objectName, objectIDs, db, params, comMast
|
|
|
793
793
|
return __generator(this, function (_k) {
|
|
794
794
|
switch (_k.label) {
|
|
795
795
|
case 0:
|
|
796
|
-
_k.trys.push([0,
|
|
796
|
+
_k.trys.push([0, 7, , 8]);
|
|
797
797
|
querys = [];
|
|
798
798
|
return [4 /*yield*/, db.collection('ObjectSchema').aggregate([{ $unwind: "$Fields" },
|
|
799
799
|
{ $match: { $or: [{ "Fields.LookupObject": objectName }, { "Fields.ExtraLookupObjects": { $elemMatch: { "from": objectName } } }] } },
|
|
800
800
|
], mongoQueryOpts).toArray()];
|
|
801
801
|
case 1:
|
|
802
802
|
data = _k.sent();
|
|
803
|
-
if (!(data && data.length > 0)) return [3 /*break*/,
|
|
803
|
+
if (!(data && data.length > 0)) return [3 /*break*/, 6];
|
|
804
804
|
i = 0;
|
|
805
805
|
_k.label = 2;
|
|
806
806
|
case 2:
|
|
@@ -872,33 +872,38 @@ function DeleteFieldInOtherCollection(objectName, objectIDs, db, params, comMast
|
|
|
872
872
|
i++;
|
|
873
873
|
return [3 /*break*/, 2];
|
|
874
874
|
case 5:
|
|
875
|
-
if (
|
|
876
|
-
|
|
875
|
+
if (querys.length > 0) {
|
|
876
|
+
for (i = 0; i < querys.length; i++) {
|
|
877
|
+
query = querys[i];
|
|
878
|
+
dbConnection = (query.UseMasterDatabase) ? comMasterDb : db;
|
|
879
|
+
if ((query === null || query === void 0 ? void 0 : query.UseMasterDatabase) && mongoQueryOpts && Object.keys(mongoQueryOpts).length != 0) {
|
|
880
|
+
// not sending mongoQueryOpts in the query for not to send the sessions against the master Database.
|
|
881
|
+
if (query.arrayFilters !== undefined) {
|
|
882
|
+
dbConnection.collection(query.ObjectName).updateMany(query.match, { $set: query.set }, { arrayFilters: [query.arrayFilters] });
|
|
883
|
+
}
|
|
884
|
+
else {
|
|
885
|
+
dbConnection.collection(query.ObjectName).updateMany(query.match, { $set: query.set });
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
else {
|
|
889
|
+
if (query.arrayFilters !== undefined) {
|
|
890
|
+
dbConnection.collection(query.ObjectName).updateMany(query.match, { $set: query.set }, __assign({ arrayFilters: [query.arrayFilters] }, mongoQueryOpts));
|
|
891
|
+
}
|
|
892
|
+
else {
|
|
893
|
+
dbConnection.collection(query.ObjectName).updateMany(query.match, { $set: query.set }, mongoQueryOpts);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
}
|
|
877
898
|
_k.label = 6;
|
|
878
899
|
case 6:
|
|
879
|
-
if (!(i < querys.length)) return [3 /*break*/, 11];
|
|
880
|
-
query = querys[i];
|
|
881
|
-
dbConnection = (query.UseMasterDatabase) ? comMasterDb : db;
|
|
882
|
-
if (!(query.arrayFilters !== undefined)) return [3 /*break*/, 8];
|
|
883
|
-
return [4 /*yield*/, dbConnection.collection(query.ObjectName).updateMany(query.match, { $set: query.set }, __assign({ arrayFilters: [query.arrayFilters] }, mongoQueryOpts))];
|
|
884
|
-
case 7:
|
|
885
|
-
_k.sent();
|
|
886
|
-
return [3 /*break*/, 10];
|
|
887
|
-
case 8: return [4 /*yield*/, dbConnection.collection(query.ObjectName).updateMany(query.match, { $set: query.set }, mongoQueryOpts)];
|
|
888
|
-
case 9:
|
|
889
|
-
_k.sent();
|
|
890
|
-
_k.label = 10;
|
|
891
|
-
case 10:
|
|
892
|
-
i++;
|
|
893
|
-
return [3 /*break*/, 6];
|
|
894
|
-
case 11:
|
|
895
900
|
resolve();
|
|
896
|
-
return [3 /*break*/,
|
|
897
|
-
case
|
|
901
|
+
return [3 /*break*/, 8];
|
|
902
|
+
case 7:
|
|
898
903
|
error_1 = _k.sent();
|
|
899
904
|
reject(error_1);
|
|
900
|
-
return [3 /*break*/,
|
|
901
|
-
case
|
|
905
|
+
return [3 /*break*/, 8];
|
|
906
|
+
case 8: return [2 /*return*/];
|
|
902
907
|
}
|
|
903
908
|
});
|
|
904
909
|
}); })];
|
|
@@ -993,10 +998,23 @@ function DeleteFieldInOtherCollection(objectName, objectIDs, db, params, comMast
|
|
|
993
998
|
for (i = 0; i < querys_1.length; i++) {
|
|
994
999
|
query = querys_1[i];
|
|
995
1000
|
dbConnection = (query.UseMasterDatabase) ? comMasterDb : db;
|
|
996
|
-
if (query.
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1001
|
+
if ((query === null || query === void 0 ? void 0 : query.UseMasterDatabase) && mongoQueryOpts && Object.keys(mongoQueryOpts).length != 0) {
|
|
1002
|
+
// not sending mongoQueryOpts in the query for not to send the sessions against the master Database.
|
|
1003
|
+
if (query.arrayFilters !== undefined) {
|
|
1004
|
+
dbConnection.collection(query.ObjectName).updateMany(query.match, { $set: query.set }, { arrayFilters: [query.arrayFilters] });
|
|
1005
|
+
}
|
|
1006
|
+
else {
|
|
1007
|
+
dbConnection.collection(query.ObjectName).updateMany(query.match, { $set: query.set });
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
else {
|
|
1011
|
+
if (query.arrayFilters !== undefined) {
|
|
1012
|
+
dbConnection.collection(query.ObjectName).updateMany(query.match, { $set: query.set }, __assign({ arrayFilters: [query.arrayFilters] }, mongoQueryOpts));
|
|
1013
|
+
}
|
|
1014
|
+
else {
|
|
1015
|
+
dbConnection.collection(query.ObjectName).updateMany(query.match, { $set: query.set }, mongoQueryOpts);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1000
1018
|
}
|
|
1001
1019
|
}
|
|
1002
1020
|
_k.label = 5;
|