@7365admin1/module-hygiene 4.19.0 → 4.21.0

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/index.mjs CHANGED
@@ -4805,7 +4805,7 @@ function useSupplyRepository() {
4805
4805
  throw new BadRequestError18("Invalid site ID format.");
4806
4806
  }
4807
4807
  if (search) {
4808
- query.$text = { $search: search };
4808
+ query.name = { $regex: search, $options: "i" };
4809
4809
  cacheOptions.search = search;
4810
4810
  }
4811
4811
  const cacheKey = makeCacheKey6(namespace_collection, cacheOptions);
@@ -5495,6 +5495,7 @@ function useCheckOutItemRepository() {
5495
5495
  { key: { site: 1 } },
5496
5496
  { key: { serviceType: 1 } },
5497
5497
  { key: { supply: 1 } },
5498
+ { key: { createdBy: 1 } },
5498
5499
  { key: { status: 1 } }
5499
5500
  ]);
5500
5501
  } catch (error) {
@@ -5526,7 +5527,11 @@ function useCheckOutItemRepository() {
5526
5527
  });
5527
5528
  return res.insertedId;
5528
5529
  } catch (error) {
5529
- throw error;
5530
+ if (error.code === 11e3) {
5531
+ throw "The Item is already exisits";
5532
+ } else {
5533
+ throw error;
5534
+ }
5530
5535
  }
5531
5536
  }
5532
5537
  async function getCheckOutItems({
@@ -5554,7 +5559,7 @@ function useCheckOutItemRepository() {
5554
5559
  throw new BadRequestError25("Invalid site ID format.");
5555
5560
  }
5556
5561
  if (search) {
5557
- query.$text = { $search: search };
5562
+ query.supplyName = { $regex: search, $options: "i" };
5558
5563
  cacheOptions.search = search;
5559
5564
  }
5560
5565
  const cacheKey = makeCacheKey8(namespace_collection, cacheOptions);
@@ -5592,11 +5597,35 @@ function useCheckOutItemRepository() {
5592
5597
  preserveNullAndEmptyArrays: true
5593
5598
  }
5594
5599
  },
5600
+ {
5601
+ $lookup: {
5602
+ from: "users",
5603
+ let: { createdByStr: "$createdBy" },
5604
+ pipeline: [
5605
+ {
5606
+ $match: {
5607
+ $expr: {
5608
+ $eq: [{ $toString: "$_id" }, "$$createdByStr"]
5609
+ }
5610
+ }
5611
+ },
5612
+ { $project: { profile: 1 } }
5613
+ ],
5614
+ as: "createdByDoc"
5615
+ }
5616
+ },
5617
+ {
5618
+ $unwind: {
5619
+ path: "$createdByDoc",
5620
+ preserveNullAndEmptyArrays: true
5621
+ }
5622
+ },
5595
5623
  {
5596
5624
  $project: {
5597
5625
  supplyName: 1,
5598
5626
  supplyQty: "$supplyDoc.qty",
5599
5627
  checkOutByName: "$createdByName",
5628
+ profile: "$createdByDoc.profile",
5600
5629
  checkOutQty: "$qty",
5601
5630
  createdAt: 1,
5602
5631
  status: 1