my-typescript-library-rahul52us 2.3.4 → 2.3.6

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.
@@ -167,804 +167,6 @@ interface Data {
167
167
  count: number;
168
168
  }
169
169
 
170
- // export async function getAllDocument(
171
- // workflowData: any,
172
- // noOfLevels: number,
173
- // workflow: string,
174
- // searchValue: string,
175
- // status: string,
176
- // company: string,
177
- // userId: any,
178
- // differentiateFirstLevel: any,
179
- // level: string,
180
- // sort: string | null = "1",
181
- // limit: string | null = "10",
182
- // page: string | null = "1",
183
- // exchangeType: any | null,
184
- // billType: string | null,
185
- // manual: string | null,
186
- // startDate: any,
187
- // endDate: any,
188
- // searchField: any,
189
- // dateFilterKey: string,
190
- // sortByKey: string,
191
- // additionalFiles: string[]
192
- // ) {
193
- // try {
194
- // let matchQuery: any = {};
195
- // if (searchField && searchValue?.trim()) {
196
- // matchQuery[`originalValues.${searchField}`] = {
197
- // $regex: searchValue,
198
- // $options: "i",
199
- // };
200
- // }
201
-
202
- // if (startDate) {
203
- // matchQuery[dateFilterKey] = { $gte: new Date(startDate) };
204
- // }
205
-
206
- // if (endDate) {
207
- // matchQuery[dateFilterKey] = {
208
- // ...matchQuery[dateFilterKey],
209
- // $lte: new Date(endDate),
210
- // };
211
- // }
212
-
213
- // var matchConditions: any = {
214
- // ...matchQuery,
215
- // // company: new mongoose.Types.ObjectId(company),
216
- // workflow: new mongoose.Types.ObjectId(workflow),
217
- // deleted_At: { $exists: false },
218
- // };
219
-
220
- // if (level === workflowData?.values?.approvalLevel) {
221
- // matchConditions.isguaranteed = { $eq: true };
222
- // }
223
-
224
- // if (exchangeType && Array.isArray(exchangeType)) {
225
- // exchangeType.forEach((typeObj) => {
226
- // Object.entries(typeObj).forEach(([field, value]) => {
227
- // if (!matchConditions[`originalValues.${field}`]) {
228
- // matchConditions[`originalValues.${field}`] = [];
229
- // }
230
- // matchConditions[`originalValues.${field}`].push(value);
231
- // });
232
- // });
233
- // }
234
-
235
- // Object.entries(matchConditions).forEach(([field, value]) => {
236
- // if (Array.isArray(value)) {
237
- // matchConditions[field] = { $in: value };
238
- // }
239
- // });
240
-
241
- // let pipeline: any = [];
242
-
243
- // let expr: any = {};
244
-
245
- // let levels = generateLevels(noOfLevels);
246
- // switch (level) {
247
- // case levels[0]:
248
- // switch (status) {
249
- // case "pending":
250
- // expr = {
251
- // $expr: {
252
- // $and: [
253
- // {
254
- // $and: [
255
- // {
256
- // $not: [
257
- // {
258
- // $and: [
259
- // {
260
- // $in: [
261
- // { $arrayElemAt: ["$approval.status", -1] },
262
- // ["approved", "rejected"],
263
- // ],
264
- // },
265
- // {
266
- // $in: [
267
- // { $arrayElemAt: ["$approval.level", -1] },
268
- // [levels[0]],
269
- // ],
270
- // },
271
- // ],
272
- // },
273
- // ],
274
- // },
275
- // {
276
- // $not: [
277
- // {
278
- // $and: [
279
- // {
280
- // $in: [
281
- // { $arrayElemAt: ["$approval.status", -1] },
282
- // ["approved"],
283
- // ],
284
- // },
285
- // {
286
- // $in: [
287
- // { $arrayElemAt: ["$approval.level", -1] },
288
- // [levels[levels.length - 1]],
289
- // ],
290
- // },
291
- // ],
292
- // },
293
- // ],
294
- // },
295
- // ],
296
- // },
297
- // ],
298
- // },
299
- // };
300
- // break;
301
- // case "approved":
302
- // expr = {
303
- // $expr: {
304
- // $or: [
305
- // {
306
- // $and: [
307
- // {
308
- // $in: [
309
- // { $arrayElemAt: ["$approval.status", -1] },
310
- // [status],
311
- // ],
312
- // },
313
- // {
314
- // $in: [
315
- // { $arrayElemAt: ["$approval.level", -1] },
316
- // [levels[levels.length - 1], levels[0]],
317
- // ],
318
- // },
319
- // {
320
- // $not: [{ $eq: ["$approval", []] }],
321
- // },
322
- // ],
323
- // },
324
- // ],
325
- // },
326
- // };
327
- // break;
328
- // case "rejected":
329
- // expr = {
330
- // $expr: {
331
- // $or: [
332
- // {
333
- // $and: [
334
- // {
335
- // $in: [
336
- // { $arrayElemAt: ["$approval.status", -1] },
337
- // [status],
338
- // ],
339
- // },
340
- // {
341
- // $in: [
342
- // { $arrayElemAt: ["$approval.level", -1] },
343
- // [levels[0]],
344
- // ],
345
- // },
346
- // {
347
- // $not: [{ $eq: ["$approval", []] }],
348
- // },
349
- // ],
350
- // },
351
- // ],
352
- // },
353
- // };
354
- // break;
355
- // }
356
-
357
- // pipeline = [
358
- // {
359
- // $match: {
360
- // ...matchConditions,
361
- // ...expr,
362
- // },
363
- // },
364
- // ];
365
- // break;
366
- // default:
367
- // let { approvedRoles, rejectedRoles, approvedBy, rejectedBy } =
368
- // getDynamicRoles(noOfLevels, level);
369
- // switch (status) {
370
- // case "pending":
371
- // expr = {
372
- // $expr: {
373
- // $or: [
374
- // {
375
- // $and: [
376
- // {
377
- // $and: [
378
- // {
379
- // $not: [
380
- // {
381
- // $and: [
382
- // {
383
- // $in: [
384
- // {
385
- // $arrayElemAt: ["$approval.status", -1],
386
- // },
387
- // ["approved"],
388
- // ],
389
- // },
390
- // {
391
- // $in: [
392
- // {
393
- // $arrayElemAt: ["$approval.level", -1],
394
- // },
395
- // approvedRoles,
396
- // ],
397
- // },
398
- // ],
399
- // },
400
- // ],
401
- // },
402
- // {
403
- // $not: [
404
- // {
405
- // $and: [
406
- // {
407
- // $in: [
408
- // {
409
- // $arrayElemAt: ["$approval.status", -1],
410
- // },
411
- // ["rejected"],
412
- // ],
413
- // },
414
- // {
415
- // $in: [
416
- // {
417
- // $arrayElemAt: ["$approval.level", -1],
418
- // },
419
- // rejectedRoles,
420
- // ],
421
- // },
422
- // ],
423
- // },
424
- // ],
425
- // },
426
- // level !== levels[1] && {
427
- // $and: [
428
- // {
429
- // $in: [
430
- // {
431
- // $arrayElemAt: ["$approval.status", -1],
432
- // },
433
- // ["approved"],
434
- // ],
435
- // },
436
- // {
437
- // $in: [
438
- // {
439
- // $arrayElemAt: ["$approval.level", -1],
440
- // },
441
- // approvedBy,
442
- // ],
443
- // },
444
- // ],
445
- // },
446
- // {
447
- // $not: [{ $eq: ["$approval", []] }],
448
- // },
449
- // ],
450
- // },
451
- // ],
452
- // },
453
- // level !== levels[levels.length - 1] && {
454
- // $and: [
455
- // {
456
- // $in: [
457
- // {
458
- // $arrayElemAt: ["$approval.status", -1],
459
- // },
460
- // ["rejected"],
461
- // ],
462
- // },
463
- // {
464
- // $in: [
465
- // {
466
- // $arrayElemAt: ["$approval.level", -1],
467
- // },
468
- // rejectedBy,
469
- // ],
470
- // },
471
- // ],
472
- // },
473
- // level === levels[1] && {
474
- // $and: [
475
- // {
476
- // $eq: ["$tags.extraction.type", "automatic"],
477
- // },
478
- // { $eq: ["$approval", []] },
479
- // ],
480
- // },
481
- // ],
482
- // },
483
- // };
484
-
485
- // // Only add the userId check for the first level if approval is not empty
486
- // let userIdCheck = {};
487
- // if (level === levels[1] && differentiateFirstLevel) {
488
- // userIdCheck = {
489
- // approval: {
490
- // $elemMatch: {
491
- // userId: { $in: [userId] },
492
- // level: levels[1],
493
- // },
494
- // },
495
- // };
496
- // }
497
-
498
- // pipeline = [
499
- // {
500
- // $match: {
501
- // ...matchConditions,
502
- // ...expr,
503
- // ...userIdCheck,
504
- // },
505
- // },
506
- // ];
507
- // break;
508
- // case "approved":
509
- // pipeline = [
510
- // {
511
- // $addFields: {
512
- // filteredApproval: {
513
- // $filter: {
514
- // input: "$approval",
515
- // as: "item",
516
- // cond: { $eq: ["$$item.level", level] },
517
- // },
518
- // },
519
- // },
520
- // },
521
- // {
522
- // $match: {
523
- // ...matchConditions,
524
- // $expr: {
525
- // $and: [
526
- // {
527
- // $and: [
528
- // {
529
- // $eq: [
530
- // {
531
- // $arrayElemAt: ["$filteredApproval.status", -1],
532
- // },
533
- // status,
534
- // ],
535
- // },
536
- // ],
537
- // },
538
- // {
539
- // $cond: {
540
- // if: differentiateFirstLevel,
541
- // then: {
542
- // $eq: [
543
- // {
544
- // $arrayElemAt: ["$filteredApproval.userId", -1],
545
- // },
546
- // userId,
547
- // ],
548
- // },
549
- // else: true,
550
- // },
551
- // },
552
- // {
553
- // $not: [{ $eq: ["$approval", []] }],
554
- // },
555
- // {
556
- // $not: [
557
- // {
558
- // $and: [
559
- // {
560
- // $in: [
561
- // {
562
- // $arrayElemAt: ["$approval.status", -1],
563
- // },
564
- // ["rejected"],
565
- // ],
566
- // },
567
- // {
568
- // $in: [
569
- // {
570
- // $arrayElemAt: ["$approval.level", -1],
571
- // },
572
- // rejectedBy,
573
- // ],
574
- // },
575
- // ],
576
- // },
577
- // ],
578
- // },
579
- // // {
580
- // // $not: [
581
- // // {
582
- // // $and: [
583
- // // {
584
- // // $in: [
585
- // // {
586
- // // $arrayElemAt: ["$approval.status", -1],
587
- // // },
588
- // // ["approved"],
589
- // // ],
590
- // // },
591
- // // {
592
- // // $in: [
593
- // // {
594
- // // $arrayElemAt: ["$approval.level", -1],
595
- // // },
596
- // // approvedBy,
597
- // // ],
598
- // // },
599
- // // ],
600
- // // },
601
- // // ],
602
- // // }
603
- // ],
604
- // },
605
- // },
606
- // },
607
- // ];
608
- // break;
609
- // case "rejected":
610
- // pipeline = [
611
- // {
612
- // $addFields: {
613
- // filteredApproval: {
614
- // $filter: {
615
- // input: "$approval",
616
- // as: "item",
617
- // cond: { $eq: ["$$item.level", level] },
618
- // },
619
- // },
620
- // },
621
- // },
622
- // {
623
- // $match: {
624
- // ...matchConditions,
625
- // $expr: {
626
- // $and: [
627
- // {
628
- // $and: [
629
- // {
630
- // $eq: [
631
- // {
632
- // $arrayElemAt: ["$filteredApproval.status", -1],
633
- // },
634
- // status,
635
- // ],
636
- // },
637
- // ],
638
- // },
639
- // {
640
- // $cond: {
641
- // if: differentiateFirstLevel,
642
- // then: {
643
- // $eq: [
644
- // {
645
- // $arrayElemAt: ["$filteredApproval.userId", -1],
646
- // },
647
- // userId,
648
- // ],
649
- // },
650
- // else: true,
651
- // },
652
- // },
653
- // {
654
- // $not: [{ $eq: ["$approval", []] }],
655
- // },
656
- // // {
657
- // // $not: [
658
- // // {
659
- // // $and: [
660
- // // {
661
- // // $in: [
662
- // // {
663
- // // $arrayElemAt: ["$approval.status", -1],
664
- // // },
665
- // // ["rejected"],
666
- // // ],
667
- // // },
668
- // // {
669
- // // $in: [
670
- // // {
671
- // // $arrayElemAt: ["$approval.level", -1],
672
- // // },
673
- // // rejectedBy,
674
- // // ],
675
- // // },
676
- // // ],
677
- // // },
678
- // // ],
679
- // // },
680
- // {
681
- // $not: [
682
- // {
683
- // $and: [
684
- // {
685
- // $in: [
686
- // {
687
- // $arrayElemAt: ["$approval.status", -1],
688
- // },
689
- // ["approved"],
690
- // ],
691
- // },
692
- // {
693
- // $in: [
694
- // {
695
- // $arrayElemAt: ["$approval.level", -1],
696
- // },
697
- // approvedBy,
698
- // ],
699
- // },
700
- // ],
701
- // },
702
- // ],
703
- // },
704
- // ],
705
- // },
706
- // },
707
- // },
708
- // ];
709
- // }
710
- // break;
711
- // }
712
-
713
- // if (manual && (level === levels[0] || level === levels[1])) {
714
- // pipeline = [
715
- // {
716
- // $match: {
717
- // ...matchQuery,
718
- // ...matchConditions,
719
- // "tags.extraction.type": "manual",
720
- // approval: { $eq: [] },
721
- // },
722
- // },
723
- // ];
724
- // } else if (manual) {
725
- // return {
726
- // data: [],
727
- // totalPages: 0,
728
- // };
729
- // }
730
-
731
- // const approvalStage: any = [
732
- // {
733
- // $unwind: {
734
- // path: "$approval",
735
- // preserveNullAndEmptyArrays: true,
736
- // },
737
- // },
738
- // {
739
- // $lookup: {
740
- // from: "fs.files",
741
- // localField: "approval.fileId",
742
- // foreignField: "_id",
743
- // as: "approval.fileDetails",
744
- // },
745
- // },
746
- // {
747
- // $unwind: {
748
- // path: "$approval.fileDetails",
749
- // preserveNullAndEmptyArrays: true,
750
- // },
751
- // },
752
- // {
753
- // $lookup: {
754
- // from: "accounts",
755
- // localField: "approval.userId",
756
- // foreignField: "_id",
757
- // as: "approval.userDetails",
758
- // pipeline: [
759
- // {
760
- // $project: {
761
- // _id: 1,
762
- // username: 1,
763
- // role: 1,
764
- // level: 1,
765
- // },
766
- // },
767
- // ],
768
- // },
769
- // },
770
- // {
771
- // $unwind: {
772
- // path: "$approval.userDetails",
773
- // preserveNullAndEmptyArrays: true,
774
- // },
775
- // },
776
- // {
777
- // $group: {
778
- // _id: "$_id",
779
- // document: { $first: "$$ROOT" },
780
- // approvals: {
781
- // $push: {
782
- // $mergeObjects: [
783
- // "$approval",
784
- // {
785
- // file: "$approval.fileDetails",
786
- // user: "$approval.userDetails",
787
- // },
788
- // ],
789
- // },
790
- // },
791
- // },
792
- // },
793
- // {
794
- // $addFields: {
795
- // "document.approval": {
796
- // $filter: {
797
- // input: "$approvals",
798
- // as: "approval",
799
- // cond: { $ne: ["$$approval", {}] },
800
- // },
801
- // },
802
- // },
803
- // },
804
- // {
805
- // $replaceRoot: {
806
- // newRoot: "$document",
807
- // },
808
- // },
809
- // {
810
- // $project: {
811
- // "approval.fileDetails": 0,
812
- // "approval.userDetails": 0,
813
- // },
814
- // },
815
- // ];
816
-
817
- // const lookupStages = additionalFiles.map((obj: any) => ({
818
- // $lookup: {
819
- // from: "fs.files",
820
- // localField: `additionalFiles.${obj}`,
821
- // foreignField: "_id",
822
- // as: obj,
823
- // },
824
- // }));
825
-
826
-
827
- // pipeline = [
828
- // ...pipeline,
829
- // {
830
- // $lookup: {
831
- // from: "fs.files",
832
- // localField: "file",
833
- // foreignField: "_id",
834
- // as: "file",
835
- // },
836
- // },
837
- // {
838
- // "$unwind": {
839
- // "path": "$additionalFiles",
840
- // "preserveNullAndEmptyArrays": true
841
- // }
842
- // },
843
- // {
844
- // "$lookup": {
845
- // "from": "fs.files",
846
- // "localField": "additionalFiles.fileId",
847
- // "foreignField": "_id",
848
- // "as": "lookupResult"
849
- // }
850
- // },
851
- // {
852
- // "$addFields": {
853
- // "lookupResult": {
854
- // "$cond": {
855
- // "if": { "$eq": [{ "$size": "$lookupResult" }, 0] },
856
- // "then": [{}],
857
- // "else": "$lookupResult"
858
- // }
859
- // }
860
- // }
861
- // },
862
- // {
863
- // "$group": {
864
- // "_id": "$_id",
865
- // "originalFields": { "$first": "$$ROOT" },
866
- // "additionalFilesDetails": {
867
- // "$push": {
868
- // "$mergeObjects": [
869
- // "$additionalFiles",
870
- // { "$first": "$lookupResult" }
871
- // ]
872
- // }
873
- // }
874
- // }
875
- // },
876
- // {
877
- // "$replaceRoot": {
878
- // "newRoot": {
879
- // "$mergeObjects": ["$originalFields", { "additionalFilesDetails": "$additionalFilesDetails" }]
880
- // }
881
- // }
882
- // },
883
- // {
884
- // $lookup: {
885
- // from: "fs.files",
886
- // localField: "filexls",
887
- // foreignField: "_id",
888
- // as: "filexls",
889
- // },
890
- // },
891
- // ...lookupStages,
892
- // ...approvalStage,
893
- // ];
894
-
895
- // // pipeline = [
896
- // // ...pipeline,
897
- // // {
898
- // // $lookup: {
899
- // // from: "fs.files",
900
- // // localField: "file",
901
- // // foreignField: "_id",
902
- // // as: "file",
903
- // // },
904
- // // },
905
- // // {
906
- // // $lookup: {
907
- // // from: "fs.files",
908
- // // localField: "additionalFiles",
909
- // // foreignField: "_id",
910
- // // as: "additionalFilesDetails",
911
- // // },
912
- // // },
913
- // // {
914
- // // $lookup: {
915
- // // from: "fs.files",
916
- // // localField: "filexls",
917
- // // foreignField: "_id",
918
- // // as: "filexls",
919
- // // },
920
- // // },
921
- // // // ...lookupStages,
922
- // // ...approvalStage,
923
- // // ];
924
-
925
- // if (sortByKey) {
926
- // const sortStage: any = {};
927
- // if (sortByKey === "created_At" || sortByKey === "updated_At") {
928
- // sortStage[`${sortByKey}`] = Number(sort);
929
- // } else {
930
- // sortStage[`originalValues.${sortByKey}`] = Number(sort);
931
- // }
932
- // pipeline.push({
933
- // $sort: sortStage,
934
- // });
935
- // }
936
-
937
- // let countPipeline = [
938
- // ...pipeline,
939
- // { $group: { _id: null, count: { $sum: 1 } } },
940
- // ];
941
- // if (limit && page) {
942
- // const skip = (parseInt(page) - 1) * parseInt(limit);
943
- // pipeline.push({ $skip: skip } as any, { $limit: parseInt(limit) } as any);
944
- // }
945
-
946
- // const [pendingData, totalCount]: any = await Promise.all([
947
- // Document.aggregate(pipeline),
948
- // Document.aggregate(countPipeline),
949
- // ]);
950
-
951
- // // fs.writeFileSync('aggregationResult.json', JSON.stringify(pipeline, null, 2));
952
-
953
- // let totalPages;
954
- // if (limit) {
955
- // totalPages = Math.ceil(totalCount?.[0]?.count / parseInt(limit));
956
- // }
957
-
958
- // return {
959
- // data: pendingData,
960
- // totalPages,
961
- // };
962
- // } catch (error) {
963
- // console.log(error?.message);
964
- // throw new Error(error.message);
965
- // }
966
- // }
967
-
968
170
  export async function getAllDocument(
969
171
  noOfLevels: number,
970
172
  workflow: string,
@@ -1617,66 +819,6 @@ export async function getAllDocument(
1617
819
  },
1618
820
  }));
1619
821
 
1620
- pipeline = [
1621
- ...pipeline,
1622
- {
1623
- $lookup: {
1624
- from: "fs.files",
1625
- localField: "file",
1626
- foreignField: "_id",
1627
- as: "file",
1628
- },
1629
- },
1630
- {
1631
- $addFields: {
1632
- additionalFileIds: {
1633
- $reduce: {
1634
- input: "$additionalFiles",
1635
- initialValue: [],
1636
- in: {
1637
- $concatArrays: [
1638
- "$$value",
1639
- [
1640
- {
1641
- $cond: {
1642
- if: { $isArray: "$$this" },
1643
- then: "$$this",
1644
- else: {
1645
- $let: {
1646
- vars: {
1647
- key: { $arrayElemAt: [{ $objectToArray: "$$this" }, 0] },
1648
- },
1649
- in: "$$key.v",
1650
- },
1651
- },
1652
- },
1653
- },
1654
- ],
1655
- ],
1656
- },
1657
- },
1658
- },
1659
- },
1660
- },
1661
- {
1662
- $lookup: {
1663
- from: "fs.files",
1664
- localField: "additionalFileIds",
1665
- foreignField: "_id",
1666
- as: "additionalFilesDetails",
1667
- },
1668
- },
1669
- {
1670
- $lookup: {
1671
- from: "fs.files",
1672
- localField: "filexls",
1673
- foreignField: "_id",
1674
- as: "filexls",
1675
- },
1676
- },
1677
- ...lookupStages,
1678
- ...approvalStage,
1679
- ];
1680
822
 
1681
823
  // pipeline = [
1682
824
  // ...pipeline,
@@ -1689,59 +831,50 @@ export async function getAllDocument(
1689
831
  // },
1690
832
  // },
1691
833
  // {
1692
- // $unwind: {
1693
- // path: "$additionalFiles",
1694
- // preserveNullAndEmptyArrays: true,
1695
- // },
834
+ // "$unwind": {
835
+ // "path": "$additionalFiles",
836
+ // "preserveNullAndEmptyArrays": true
837
+ // }
1696
838
  // },
1697
839
  // {
1698
- // $lookup: {
1699
- // from: "fs.files",
1700
- // localField: "additionalFiles.fileId",
1701
- // foreignField: "_id",
1702
- // as: "lookupResult",
1703
- // },
840
+ // "$lookup": {
841
+ // "from": "fs.files",
842
+ // "localField": "additionalFiles.fileId",
843
+ // "foreignField": "_id",
844
+ // "as": "lookupResult"
845
+ // }
1704
846
  // },
1705
847
  // {
1706
- // $addFields: {
1707
- // lookupResult: {
1708
- // $cond: {
1709
- // if: { $eq: [{ $size: "$lookupResult" }, 0] },
1710
- // then: [{}],
1711
- // else: "$lookupResult",
1712
- // },
1713
- // },
1714
- // },
848
+ // "$addFields": {
849
+ // "lookupResult": {
850
+ // "$cond": {
851
+ // "if": { "$eq": [{ "$size": "$lookupResult" }, 0] },
852
+ // "then": [{}],
853
+ // "else": "$lookupResult"
854
+ // }
855
+ // }
856
+ // }
1715
857
  // },
1716
858
  // {
1717
- // $group: {
1718
- // _id: "$_id",
1719
- // originalFields: { $first: "$$ROOT" },
1720
- // additionalFilesDetails: {
1721
- // $push: {
1722
- // $cond: {
1723
- // if: { $or: [{ $eq: ["$additionalFiles", null] }, { $eq: ["$additionalFiles", {}] }] },
1724
- // then: {},
1725
- // else: {
1726
- // $mergeObjects: [
1727
- // { fileId: "$additionalFiles.fileId" },
1728
- // { $first: "$lookupResult" },
1729
- // ],
1730
- // },
1731
- // },
1732
- // },
1733
- // },
1734
- // },
859
+ // "$group": {
860
+ // "_id": "$_id",
861
+ // "originalFields": { "$first": "$$ROOT" },
862
+ // "additionalFilesDetails": {
863
+ // "$push": {
864
+ // "$mergeObjects": [
865
+ // "$additionalFiles",
866
+ // { "$first": "$lookupResult" }
867
+ // ]
868
+ // }
869
+ // }
870
+ // }
1735
871
  // },
1736
872
  // {
1737
- // $replaceRoot: {
1738
- // newRoot: {
1739
- // $mergeObjects: [
1740
- // "$originalFields",
1741
- // { additionalFilesDetails: "$additionalFilesDetails" },
1742
- // ],
1743
- // },
1744
- // },
873
+ // "$replaceRoot": {
874
+ // "newRoot": {
875
+ // "$mergeObjects": ["$originalFields", { "additionalFilesDetails": "$additionalFilesDetails" }]
876
+ // }
877
+ // }
1745
878
  // },
1746
879
  // {
1747
880
  // $lookup: {
@@ -1755,35 +888,35 @@ export async function getAllDocument(
1755
888
  // ...approvalStage,
1756
889
  // ];
1757
890
 
1758
- // pipeline = [
1759
- // ...pipeline,
1760
- // {
1761
- // $lookup: {
1762
- // from: "fs.files",
1763
- // localField: "file",
1764
- // foreignField: "_id",
1765
- // as: "file",
1766
- // },
1767
- // },
1768
- // {
1769
- // $lookup: {
1770
- // from: "fs.files",
1771
- // localField: "additionalFiles",
1772
- // foreignField: "_id",
1773
- // as: "additionalFilesDetails",
1774
- // },
1775
- // },
1776
- // {
1777
- // $lookup: {
1778
- // from: "fs.files",
1779
- // localField: "filexls",
1780
- // foreignField: "_id",
1781
- // as: "filexls",
1782
- // },
1783
- // },
1784
- // // ...lookupStages,
891
+ pipeline = [
892
+ // ...pipeline,
893
+ // {
894
+ // $lookup: {
895
+ // from: "fs.files",
896
+ // localField: "file",
897
+ // foreignField: "_id",
898
+ // as: "file",
899
+ // },
900
+ // },
901
+ // {
902
+ // $lookup: {
903
+ // from: "fs.files",
904
+ // localField: "additionalFiles",
905
+ // foreignField: "_id",
906
+ // as: "additionalFilesDetails",
907
+ // },
908
+ // },
909
+ // {
910
+ // $lookup: {
911
+ // from: "fs.files",
912
+ // localField: "filexls",
913
+ // foreignField: "_id",
914
+ // as: "filexls",
915
+ // },
916
+ // },
917
+ ...lookupStages,
1785
918
  // ...approvalStage,
1786
- // ];
919
+ ];
1787
920
 
1788
921
  if (sortByKey) {
1789
922
  const sortStage: any = {};