@webtypen/webframez-core 0.3.10 → 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.
|
@@ -366,9 +366,13 @@ class DataBuilder {
|
|
|
366
366
|
};
|
|
367
367
|
}
|
|
368
368
|
if (type.unmapped) {
|
|
369
|
+
const appendData = {};
|
|
369
370
|
try {
|
|
370
|
-
if (typeof type.schema.
|
|
371
|
-
yield type.schema.beforeSave(req.body.data, req);
|
|
371
|
+
if (typeof type.schema.beforeSave === "function") {
|
|
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
|
@@ -449,9 +449,13 @@ export class DataBuilder {
|
|
|
449
449
|
}
|
|
450
450
|
|
|
451
451
|
if (type.unmapped) {
|
|
452
|
+
const appendData: any = {};
|
|
452
453
|
try {
|
|
453
|
-
if (typeof type.schema.
|
|
454
|
-
await type.schema.beforeSave(req.body.data, req);
|
|
454
|
+
if (typeof type.schema.beforeSave === "function") {
|
|
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
|
}
|