@webtypen/webframez-core 0.3.105 → 0.3.107
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 +18 -17
- 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);
|
|
@@ -429,10 +435,11 @@ class Datatable {
|
|
|
429
435
|
log("[DATATABLE_AGGREGATION" + (req.body._table ? "-" + req.body._table : "") + "]", aggr);
|
|
430
436
|
}
|
|
431
437
|
const connection = yield DBConnection_1.DBConnection.getConnection();
|
|
438
|
+
const collation = typeof this.collation === "function" ? yield this.collation(req) : this.collation;
|
|
432
439
|
const results = yield DBConnection_1.DBConnection.documentStore(connection)
|
|
433
440
|
.collection(yield this.getCollection(req))
|
|
434
441
|
.aggregate(aggr, {
|
|
435
|
-
collation
|
|
442
|
+
collation,
|
|
436
443
|
})
|
|
437
444
|
.toArray();
|
|
438
445
|
const sumsAfter = [];
|
|
@@ -451,7 +458,7 @@ class Datatable {
|
|
|
451
458
|
}
|
|
452
459
|
const stats = yield DBConnection_1.DBConnection.documentStore(connection)
|
|
453
460
|
.collection(yield this.getCollection(req))
|
|
454
|
-
.aggregate([...(aggregationStats ? aggregationStats : []), statsGroup])
|
|
461
|
+
.aggregate([...(aggregationStats ? aggregationStats : []), statsGroup], { collation })
|
|
455
462
|
.toArray();
|
|
456
463
|
if (this.onRow || this.onAttributes) {
|
|
457
464
|
for (let i in results) {
|
|
@@ -517,23 +524,17 @@ class Datatable {
|
|
|
517
524
|
}
|
|
518
525
|
getTotalData(req) {
|
|
519
526
|
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
|
-
}
|
|
527
|
+
const aggregation = [...(yield this.getAggregation(req)) || [], ...(yield this.getSubAggregation(req)) || []]
|
|
528
|
+
.map((_a) => {
|
|
529
|
+
var { skipStats } = _a, stage = __rest(_a, ["skipStats"]);
|
|
530
|
+
return stage;
|
|
531
|
+
});
|
|
533
532
|
const connection = yield DBConnection_1.DBConnection.getConnection();
|
|
534
533
|
return yield DBConnection_1.DBConnection.documentStore(connection)
|
|
535
534
|
.collection(yield this.getCollection(req))
|
|
536
|
-
.aggregate(
|
|
535
|
+
.aggregate(aggregation, {
|
|
536
|
+
collation: typeof this.collation === "function" ? yield this.collation(req) : this.collation,
|
|
537
|
+
})
|
|
537
538
|
.toArray();
|
|
538
539
|
});
|
|
539
540
|
}
|
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