@dnax/core 0.47.1 → 0.47.3

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/app/hono.ts CHANGED
@@ -555,7 +555,10 @@ function HonoInstance(): typeof app {
555
555
  response = await rest.findOne(
556
556
  collection,
557
557
  body?.id || body._id,
558
- body?.params || {}
558
+ body?.params || {},
559
+ {
560
+ withMeta: body?.withMeta || false,
561
+ }
559
562
  );
560
563
  }
561
564
  if (action == "insertOne") {
@@ -691,6 +694,15 @@ function HonoInstance(): typeof app {
691
694
  }
692
695
  }
693
696
 
697
+ if (
698
+ !col?.api?.fields?.hidden &&
699
+ !col?.api?.fields?.select &&
700
+ body?.withMeta
701
+ ) {
702
+ response.data = omit(response.data, ["password"]);
703
+ response.meta = response.meta || {};
704
+ }
705
+
694
706
  return c.json(response);
695
707
  } catch (err: any) {
696
708
  if (Cfg?.debug) console.log(err?.message | err);
@@ -817,7 +817,10 @@ class useRest {
817
817
  ): Promise<object | null> {
818
818
  return new Promise(async (resolve, reject) => {
819
819
  try {
820
- let meta = {};
820
+ let meta = {
821
+ total: 0,
822
+ count: 0,
823
+ };
821
824
  let sharedData = {};
822
825
  let docs: Array<any> | any = [];
823
826
  let useHook = options?.useHook ?? this.#useHook;
@@ -916,6 +919,15 @@ class useRest {
916
919
  });
917
920
  }
918
921
 
922
+ if (options?.withMeta) {
923
+ meta.count = docs?.length || 0;
924
+ meta.total = docs?.length || 0;
925
+ resolve({
926
+ data: docs?.length ? toJson(docs[0]) : null,
927
+ meta: meta,
928
+ });
929
+ }
930
+
919
931
  return resolve(docs?.length ? toJson(docs[0]) : null);
920
932
  } catch (err) {
921
933
  return reject(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.47.1",
3
+ "version": "0.47.3",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "bin": {
@@ -46,7 +46,7 @@
46
46
  "mime-types": "^2.1.35",
47
47
  "mingo": "^6.5.0",
48
48
  "moment": "^2.30.1",
49
- "mongodb": "^6.15.0",
49
+ "mongodb": "6.11.0",
50
50
  "nodemailer": "^6.9.14",
51
51
  "pidusage": "^4.0.0",
52
52
  "pizzip": "^3.1.8",