@webtypen/webframez-core 0.3.11 → 0.3.12

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.
@@ -69,10 +69,7 @@ export declare class DataBuilder {
69
69
  data?: undefined;
70
70
  } | {
71
71
  status: string;
72
- data: {
73
- _id: any;
74
- redirect: any;
75
- };
72
+ data: any;
76
73
  errors?: undefined;
77
74
  }>;
78
75
  delete(db: any, req: any): Promise<{
@@ -366,9 +366,13 @@ class DataBuilder {
366
366
  };
367
367
  }
368
368
  if (type.unmapped) {
369
+ const appendData = {};
369
370
  try {
370
371
  if (typeof type.schema.beforeSave === "function") {
371
- yield type.schema.beforeSave(req.body.data, req);
372
+ const result = yield type.schema.beforeSave(req.body.data, req);
373
+ if (result && result.__append_data) {
374
+ Object.assign(appendData, result.__append_data);
375
+ }
372
376
  }
373
377
  }
374
378
  catch (e) {
@@ -376,7 +380,10 @@ class DataBuilder {
376
380
  }
377
381
  try {
378
382
  if (typeof type.schema.afterSave === "function") {
379
- yield type.schema.afterSave(req.body.data, req);
383
+ const result = yield type.schema.afterSave(req.body.data, req);
384
+ if (result && result.__append_data) {
385
+ Object.assign(appendData, result.__append_data);
386
+ }
380
387
  }
381
388
  }
382
389
  catch (e) {
@@ -389,10 +396,7 @@ class DataBuilder {
389
396
  }
390
397
  return {
391
398
  status: "success",
392
- data: {
393
- _id: req.body.data._id ? req.body.data._id : "__unmapped",
394
- redirect: redirect,
395
- },
399
+ data: Object.assign({ _id: req.body.data._id ? req.body.data._id : "__unmapped", redirect: redirect }, appendData),
396
400
  };
397
401
  }
398
402
  if (!req.body.__builder_id || req.body.__builder_id.toString().trim() === "") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webtypen/webframez-core",
3
- "version": "0.3.11",
3
+ "version": "0.3.12",
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",
@@ -449,9 +449,13 @@ export class DataBuilder {
449
449
  }
450
450
 
451
451
  if (type.unmapped) {
452
+ const appendData: any = {};
452
453
  try {
453
454
  if (typeof type.schema.beforeSave === "function") {
454
- await type.schema.beforeSave(req.body.data, req);
455
+ const result = await type.schema.beforeSave(req.body.data, req);
456
+ if (result && result.__append_data) {
457
+ Object.assign(appendData, result.__append_data);
458
+ }
455
459
  }
456
460
  } catch (e: any) {
457
461
  throw e;
@@ -459,7 +463,10 @@ export class DataBuilder {
459
463
 
460
464
  try {
461
465
  if (typeof type.schema.afterSave === "function") {
462
- await type.schema.afterSave(req.body.data, req);
466
+ const result = await type.schema.afterSave(req.body.data, req);
467
+ if (result && result.__append_data) {
468
+ Object.assign(appendData, result.__append_data);
469
+ }
463
470
  }
464
471
  } catch (e: any) {
465
472
  throw e;
@@ -476,6 +483,7 @@ export class DataBuilder {
476
483
  data: {
477
484
  _id: req.body.data._id ? req.body.data._id : "__unmapped",
478
485
  redirect: redirect,
486
+ ...appendData,
479
487
  },
480
488
  };
481
489
  }