@webtypen/webframez-core 0.3.105 → 0.3.106
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/Datatable/Datatable.d.ts +1 -0
- package/dist/Datatable/Datatable.js +15 -15
- package/docs/datatables.md +11 -0
- package/package.json +1 -1
|
@@ -37,6 +37,7 @@ export declare class Datatable {
|
|
|
37
37
|
autoApplyFilter: "begin" | "end" | null;
|
|
38
38
|
autoApplySearch: "begin" | "end" | null;
|
|
39
39
|
logAggregation: boolean;
|
|
40
|
+
deferPresentation: boolean;
|
|
40
41
|
collation: Record<string, any> | ((req: Request) => Record<string, any> | Promise<Record<string, any>>);
|
|
41
42
|
defaultUnwind?: string | null;
|
|
42
43
|
disablePerPageConfig: boolean;
|
|
@@ -43,6 +43,7 @@ class Datatable {
|
|
|
43
43
|
this.autoApplyFilter = "begin";
|
|
44
44
|
this.autoApplySearch = null;
|
|
45
45
|
this.logAggregation = false;
|
|
46
|
+
this.deferPresentation = false;
|
|
46
47
|
this.collation = { locale: "de", strength: 2 };
|
|
47
48
|
this.defaultUnwind = null;
|
|
48
49
|
this.disablePerPageConfig = false;
|
|
@@ -391,7 +392,12 @@ class Datatable {
|
|
|
391
392
|
hasLimit = true;
|
|
392
393
|
}
|
|
393
394
|
if (skipStats) {
|
|
394
|
-
|
|
395
|
+
if (this.deferPresentation && !entry.$sort && entry.$skip === undefined && entry.$limit === undefined) {
|
|
396
|
+
subAggregation.push(entry);
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
aggregation.push(entry);
|
|
400
|
+
}
|
|
395
401
|
}
|
|
396
402
|
else {
|
|
397
403
|
aggregation.push(entry);
|
|
@@ -517,23 +523,17 @@ class Datatable {
|
|
|
517
523
|
}
|
|
518
524
|
getTotalData(req) {
|
|
519
525
|
return __awaiter(this, void 0, void 0, function* () {
|
|
520
|
-
const aggregation = []
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
if (skipStats) {
|
|
526
|
-
aggregation.push(entry);
|
|
527
|
-
}
|
|
528
|
-
else {
|
|
529
|
-
aggregation.push(entry);
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
}
|
|
526
|
+
const aggregation = [...(yield this.getAggregation(req)) || [], ...(yield this.getSubAggregation(req)) || []]
|
|
527
|
+
.map((_a) => {
|
|
528
|
+
var { skipStats } = _a, stage = __rest(_a, ["skipStats"]);
|
|
529
|
+
return stage;
|
|
530
|
+
});
|
|
533
531
|
const connection = yield DBConnection_1.DBConnection.getConnection();
|
|
534
532
|
return yield DBConnection_1.DBConnection.documentStore(connection)
|
|
535
533
|
.collection(yield this.getCollection(req))
|
|
536
|
-
.aggregate(
|
|
534
|
+
.aggregate(aggregation, {
|
|
535
|
+
collation: typeof this.collation === "function" ? yield this.collation(req) : this.collation,
|
|
536
|
+
})
|
|
537
537
|
.toArray();
|
|
538
538
|
});
|
|
539
539
|
}
|
package/docs/datatables.md
CHANGED
|
@@ -138,3 +138,14 @@ fields in the statistics service instead of depending on presentation projection
|
|
|
138
138
|
an object or an async request callback. Tables sorting numeric/date fields can return
|
|
139
139
|
`{ locale: "simple" }` to use matching binary indexes. Keep language collation for
|
|
140
140
|
text sorting or filters that depend on it; collation applies to the entire data query.
|
|
141
|
+
|
|
142
|
+
Exports (`getTotalData`) execute both aggregation phases with the same collation as
|
|
143
|
+
the table, without injecting page limits. Explicit limits in the table definition
|
|
144
|
+
remain effective, including bounded notification exports.
|
|
145
|
+
|
|
146
|
+
Tables can opt into `deferPresentation = true` to execute aggregation stages marked
|
|
147
|
+
`skipStats: true` after pagination, before explicit `subAggregation`. Sort/skip/limit
|
|
148
|
+
stages stay in the selection phase. Only mark cardinality-preserving display stages:
|
|
149
|
+
any join or calculation required by a filter, sort, or later selection stage must
|
|
150
|
+
remain unmarked. Exports retain all stages in their original order. The default is
|
|
151
|
+
false, so existing definitions keep their behavior until explicitly reviewed.
|
package/package.json
CHANGED