@webtypen/webframez-core 0.2.18 → 0.2.20

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.
@@ -21,6 +21,7 @@ export declare class Datatable {
21
21
  onAttributes?: Function;
22
22
  autoApplyFilter: DatatableAutoApplyType;
23
23
  autoApplySearch: DatatableAutoApplyType;
24
+ logAggregation: boolean;
24
25
  getInit(req: Request): Promise<any>;
25
26
  getAggregation(req: Request): Promise<any>;
26
27
  getSubAggregation(req: Request): Promise<any>;
@@ -24,6 +24,7 @@ class Datatable {
24
24
  this.perPage = 25;
25
25
  this.autoApplyFilter = "begin";
26
26
  this.autoApplySearch = null;
27
+ this.logAggregation = false;
27
28
  }
28
29
  getInit(req) {
29
30
  return __awaiter(this, void 0, void 0, function* () {
@@ -143,16 +144,21 @@ class Datatable {
143
144
  }
144
145
  }
145
146
  }
146
- const connection = yield DBConnection_1.DBConnection.getConnection();
147
- const results = yield connection.client
148
- .db(null)
149
- .collection(yield this.getCollection(req))
150
- .aggregate([
147
+ const aggr = [
151
148
  ...(aggregation ? aggregation : []),
152
149
  ...(!hasSkip ? [{ $skip: page ? page * this.perPage : 0 }] : []),
153
150
  ...(!hasLimit ? [{ $limit: this.perPage }] : []),
154
151
  ...(subAggregation ? subAggregation : []),
155
- ], {
152
+ ];
153
+ if (this.logAggregation) {
154
+ const { log } = console;
155
+ log("[DATATABLE_AGGREGATION" + (req.body._table ? "-" + req.body._table : "") + "]", aggr);
156
+ }
157
+ const connection = yield DBConnection_1.DBConnection.getConnection();
158
+ const results = yield connection.client
159
+ .db(null)
160
+ .collection(yield this.getCollection(req))
161
+ .aggregate(aggr, {
156
162
  collation: {
157
163
  locale: "de",
158
164
  strength: 2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webtypen/webframez-core",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "description": "The core package of the typescript based webframez (web-framework) by webtypen.de",
5
5
  "homepage": "https://webtypen.de/",
6
6
  "license": "MIT",
@@ -17,6 +17,7 @@ export class Datatable {
17
17
  onAttributes?: Function;
18
18
  autoApplyFilter: DatatableAutoApplyType = "begin";
19
19
  autoApplySearch: DatatableAutoApplyType = null;
20
+ logAggregation = false;
20
21
 
21
22
  async getInit(req: Request) {
22
23
  const out: any = { table: req.body._table };
@@ -140,24 +141,27 @@ export class Datatable {
140
141
  }
141
142
  }
142
143
 
144
+ const aggr = [
145
+ ...(aggregation ? aggregation : []),
146
+ ...(!hasSkip ? [{ $skip: page ? page * this.perPage : 0 }] : []),
147
+ ...(!hasLimit ? [{ $limit: this.perPage }] : []),
148
+ ...(subAggregation ? subAggregation : []),
149
+ ];
150
+ if (this.logAggregation) {
151
+ const { log } = console;
152
+ log("[DATATABLE_AGGREGATION" + (req.body._table ? "-" + req.body._table : "") + "]", aggr);
153
+ }
154
+
143
155
  const connection = await DBConnection.getConnection();
144
156
  const results = await connection.client
145
157
  .db(null)
146
158
  .collection(await this.getCollection(req))
147
- .aggregate(
148
- [
149
- ...(aggregation ? aggregation : []),
150
- ...(!hasSkip ? [{ $skip: page ? page * this.perPage : 0 }] : []),
151
- ...(!hasLimit ? [{ $limit: this.perPage }] : []),
152
- ...(subAggregation ? subAggregation : []),
153
- ],
154
- {
155
- collation: {
156
- locale: "de",
157
- strength: 2,
158
- },
159
- }
160
- )
159
+ .aggregate(aggr, {
160
+ collation: {
161
+ locale: "de",
162
+ strength: 2,
163
+ },
164
+ })
161
165
  .toArray();
162
166
 
163
167
  const statsGroup: any = { $group: { _id: null, count: { $sum: 1 } } };