@optimiser/common 1.0.364 → 1.0.365
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.d.ts +8 -2
- package/dist/lib/utility.js +11 -5
- package/package.json +1 -1
package/dist/lib/utility.d.ts
CHANGED
|
@@ -22,11 +22,17 @@ declare function SyncChildObjectData(pageData: AnyObjectInterface, objectID: Obj
|
|
|
22
22
|
declare function SyncParentObjectData(pageData: AnyObjectInterface, objectID: ObjectId, db: Db): Promise<void>;
|
|
23
23
|
/**
|
|
24
24
|
* Delete field in other collection after delete records
|
|
25
|
-
* @param
|
|
25
|
+
* @param objectName : ObjectName of record to which we want to delete
|
|
26
|
+
* @param objectIDs : ObjectId of the created records of above object name collection
|
|
27
|
+
* @param db : database connection || Db
|
|
28
|
+
* @param params : It includes the object of remaining arguments passing here as an argument
|
|
29
|
+
* @param params.isBuiltOnPromise : optional param need to send with params obj for to confirm function is used with promise or not!!
|
|
30
|
+
* @param params.mongoQueryOpts :optional param sending with params obj for some specific mongodb query operation, to maintain session for transactions
|
|
31
|
+
* @param comMasterDb : optional param sending to get it update and sync with master db.
|
|
26
32
|
*/
|
|
27
33
|
declare function DeleteFieldInOtherCollection(objectName: string, objectIDs: ObjectId, db: Db, params?: AnyObjectInterface, comMasterDb?: Db): Promise<void>;
|
|
28
34
|
declare function ReactivateFieldInOtherCollection(objectName: string, objectIDs: ObjectId, db: Db): void;
|
|
29
|
-
declare function SyncFieldInSameCollection(objectName: string, objectIDs: ObjectId[], db: Db, comMasterDb
|
|
35
|
+
declare function SyncFieldInSameCollection(objectName: string, objectIDs: ObjectId[], db: Db, comMasterDb?: Db): Promise<any>;
|
|
30
36
|
declare function SyncFieldInSameCollectionByObjectID(objectName: string, objectID: ObjectId, db: Db): void;
|
|
31
37
|
declare function SyncFieldInSameCollectionByObjectIDWithPromise(objectName: string, objectID: ObjectId, db: Db): Promise<any>;
|
|
32
38
|
declare function SyncFieldInOtherCollection(syncFields: AnyObjectInterface[], db: Db): Promise<any>;
|
package/dist/lib/utility.js
CHANGED
|
@@ -762,7 +762,13 @@ function SyncParentObjectData(pageData, objectID, db) {
|
|
|
762
762
|
exports.SyncParentObjectData = SyncParentObjectData;
|
|
763
763
|
/**
|
|
764
764
|
* Delete field in other collection after delete records
|
|
765
|
-
* @param
|
|
765
|
+
* @param objectName : ObjectName of record to which we want to delete
|
|
766
|
+
* @param objectIDs : ObjectId of the created records of above object name collection
|
|
767
|
+
* @param db : database connection || Db
|
|
768
|
+
* @param params : It includes the object of remaining arguments passing here as an argument
|
|
769
|
+
* @param params.isBuiltOnPromise : optional param need to send with params obj for to confirm function is used with promise or not!!
|
|
770
|
+
* @param params.mongoQueryOpts :optional param sending with params obj for some specific mongodb query operation, to maintain session for transactions
|
|
771
|
+
* @param comMasterDb : optional param sending to get it update and sync with master db.
|
|
766
772
|
*/
|
|
767
773
|
//
|
|
768
774
|
function DeleteFieldInOtherCollection(objectName, objectIDs, db, params, comMasterDb) {
|
|
@@ -1077,7 +1083,7 @@ function SyncFieldInSameCollection(objectName, objectIDs, db, comMasterDb) {
|
|
|
1077
1083
|
try {
|
|
1078
1084
|
db.collection("ObjectSchema").findOne({ 'Name': objectName }, function (err, objectSchema) {
|
|
1079
1085
|
return __awaiter(this, void 0, void 0, function () {
|
|
1080
|
-
var fieldArr_1, findObj;
|
|
1086
|
+
var fieldArr_1, findObj, dbToUse_1;
|
|
1081
1087
|
return __generator(this, function (_a) {
|
|
1082
1088
|
if (err) {
|
|
1083
1089
|
console.log("Error in function SyncFieldInSameCollection for object name ", objectName);
|
|
@@ -1091,8 +1097,8 @@ function SyncFieldInSameCollection(objectName, objectIDs, db, comMasterDb) {
|
|
|
1091
1097
|
if (objectIDs && objectIDs.length > 0) {
|
|
1092
1098
|
findObj = { '_id': { '$in': objectIDs } };
|
|
1093
1099
|
}
|
|
1094
|
-
|
|
1095
|
-
|
|
1100
|
+
dbToUse_1 = comMasterDb ? comMasterDb : db;
|
|
1101
|
+
dbToUse_1.collection(objectName).find(findObj).forEach(function (objectData) {
|
|
1096
1102
|
return __awaiter(this, void 0, void 0, function () {
|
|
1097
1103
|
var updateObj, i, fieldSchema, lookupData, searchValue, ex_1;
|
|
1098
1104
|
return __generator(this, function (_a) {
|
|
@@ -1125,7 +1131,7 @@ function SyncFieldInSameCollection(objectName, objectIDs, db, comMasterDb) {
|
|
|
1125
1131
|
return [3 /*break*/, 2];
|
|
1126
1132
|
case 5:
|
|
1127
1133
|
if (Object.keys(updateObj).length > 0) { // added by komal, QPC-8260- getting the comMasterDb from dbconnection based on UseMasterDatabase flag for updating the master db also.
|
|
1128
|
-
|
|
1134
|
+
dbToUse_1.collection(objectName).updateOne({ _id: objectData._id }, { $set: updateObj });
|
|
1129
1135
|
}
|
|
1130
1136
|
return [3 /*break*/, 7];
|
|
1131
1137
|
case 6:
|