vona-module-a-orm 5.0.43 → 5.0.45
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/index.js +16 -8
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1948,6 +1948,9 @@ class BeanModelCrudInner extends BeanModelView {
|
|
|
1948
1948
|
const dataTemp2 = this._prepareInsertDataByOptions(table, dataTemp, options);
|
|
1949
1949
|
// then
|
|
1950
1950
|
const [dataNew, dataNewOriginal] = await this.prepareData(table, dataTemp2);
|
|
1951
|
+
if (isNil(cast(dataNewOriginal).id) && Object.prototype.hasOwnProperty.call(dataNewOriginal, 'id')) {
|
|
1952
|
+
delete cast(dataNewOriginal).id;
|
|
1953
|
+
}
|
|
1951
1954
|
datas.push(dataNew);
|
|
1952
1955
|
datasOriginal.push(dataNewOriginal);
|
|
1953
1956
|
}
|
|
@@ -2494,7 +2497,7 @@ let ServiceRelations = (_dec$a = Service(), _dec2$a = BeanInfo({
|
|
|
2494
2497
|
for (let index = 0; index < entities.length; index++) {
|
|
2495
2498
|
const entity = entities[index];
|
|
2496
2499
|
if (entity[relationName]) {
|
|
2497
|
-
// donot
|
|
2500
|
+
// donot check if has id of entity[relationName], for safety
|
|
2498
2501
|
const item = await modelTarget.get({
|
|
2499
2502
|
[key]: cast(entity).id
|
|
2500
2503
|
});
|
|
@@ -2527,13 +2530,18 @@ let ServiceRelations = (_dec$a = Service(), _dec2$a = BeanInfo({
|
|
|
2527
2530
|
if (entity[relationName] && entity[relationName].length > 0) {
|
|
2528
2531
|
const entityId = cast(entity).id;
|
|
2529
2532
|
const idsTo = entity[relationName].map(item => item.id).filter(id => !isNil(id));
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2533
|
+
let idsTarget;
|
|
2534
|
+
if (idsTo.length === 0) {
|
|
2535
|
+
idsTarget = [];
|
|
2536
|
+
} else {
|
|
2537
|
+
const itemsTarget = await cast(modelTarget).__select_raw(undefined, {
|
|
2538
|
+
where: {
|
|
2539
|
+
[key]: entityId,
|
|
2540
|
+
id: idsTo
|
|
2541
|
+
}
|
|
2542
|
+
}, methodOptionsReal);
|
|
2543
|
+
idsTarget = itemsTarget.map(item => item.id);
|
|
2544
|
+
}
|
|
2537
2545
|
for (const child of entity[relationName]) {
|
|
2538
2546
|
if (!isNil(child.id) && !idsTarget.includes(child.id)) {
|
|
2539
2547
|
throw new Error(`invalid id: ${child.id}`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-module-a-orm",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.45",
|
|
5
5
|
"title": "a-orm",
|
|
6
6
|
"vonaModule": {
|
|
7
7
|
"capabilities": {
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"optionsGlobalInterfaceName": "IDecoratorModelOptions",
|
|
29
29
|
"optionsGlobalInterfaceFrom": "vona-module-a-orm",
|
|
30
30
|
"scopeResource": true,
|
|
31
|
+
"beanGeneral": true,
|
|
31
32
|
"boilerplate": "cli/model/boilerplate",
|
|
32
33
|
"metadataCustom": "cli/model/metadata/generate.ts"
|
|
33
34
|
},
|