@dnax/core 0.30.1 → 0.30.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/driver/mongo/rest.ts +17 -11
- package/package.json +1 -1
- package/types/index.ts +1 -0
package/driver/mongo/rest.ts
CHANGED
|
@@ -631,6 +631,22 @@ class useRest {
|
|
|
631
631
|
|
|
632
632
|
result.docs = toJson(result.docs);
|
|
633
633
|
|
|
634
|
+
if (options?.withMeta) {
|
|
635
|
+
meta.count = await this.#tenant.database.db
|
|
636
|
+
?.collection(collection)
|
|
637
|
+
.countDocuments({
|
|
638
|
+
...(params?.$match || {}),
|
|
639
|
+
})
|
|
640
|
+
.then((e) => e || 0)
|
|
641
|
+
.catch((err) => 0);
|
|
642
|
+
meta.total = await this.#tenant.database.db
|
|
643
|
+
?.collection(collection)
|
|
644
|
+
.estimatedDocumentCount();
|
|
645
|
+
} else {
|
|
646
|
+
meta.total = result.docs.length;
|
|
647
|
+
meta.count = result.docs.length;
|
|
648
|
+
}
|
|
649
|
+
|
|
634
650
|
if (col?.hooks?.afterFind && useHook) {
|
|
635
651
|
await col.hooks.afterFind({
|
|
636
652
|
sharedData: sharedData,
|
|
@@ -638,6 +654,7 @@ class useRest {
|
|
|
638
654
|
io: Cfg.io,
|
|
639
655
|
driver: "mongodb",
|
|
640
656
|
action: "find",
|
|
657
|
+
meta: meta,
|
|
641
658
|
count: result?.docs?.length || 0,
|
|
642
659
|
params: params,
|
|
643
660
|
session: sessionStorage(),
|
|
@@ -656,17 +673,6 @@ class useRest {
|
|
|
656
673
|
}
|
|
657
674
|
|
|
658
675
|
if (options?.withMeta) {
|
|
659
|
-
meta.count = await this.#tenant.database.db
|
|
660
|
-
?.collection(collection)
|
|
661
|
-
.countDocuments({
|
|
662
|
-
...(params?.$match || {}),
|
|
663
|
-
})
|
|
664
|
-
.then((e) => e || 0)
|
|
665
|
-
.catch((err) => 0);
|
|
666
|
-
meta.total = await this.#tenant.database.db
|
|
667
|
-
?.collection(collection)
|
|
668
|
-
.estimatedDocumentCount();
|
|
669
|
-
|
|
670
676
|
return resolve({
|
|
671
677
|
data: resultDocs,
|
|
672
678
|
meta: meta,
|
package/package.json
CHANGED
package/types/index.ts
CHANGED