vona-module-a-orm 5.0.47 → 5.0.48
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 +28 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2364,7 +2364,12 @@ let ServiceRelations = (_dec$a = Service(), _dec2$a = BeanInfo({
|
|
|
2364
2364
|
[key]: idsFrom
|
|
2365
2365
|
}
|
|
2366
2366
|
});
|
|
2367
|
-
|
|
2367
|
+
let items;
|
|
2368
|
+
if (idsFrom.length === 0) {
|
|
2369
|
+
items = [];
|
|
2370
|
+
} else {
|
|
2371
|
+
items = await modelTarget.select(options2, methodOptionsReal);
|
|
2372
|
+
}
|
|
2368
2373
|
for (const entity of entities) {
|
|
2369
2374
|
entity[relationName] = items.find(item => {
|
|
2370
2375
|
if (item[key] === cast(entity).id) {
|
|
@@ -2438,11 +2443,16 @@ let ServiceRelations = (_dec$a = Service(), _dec2$a = BeanInfo({
|
|
|
2438
2443
|
} else if (type === 'belongsToMany') {
|
|
2439
2444
|
const modelTargetMiddle = this.__getModelTarget(modelMiddle, options?.meta?.middle);
|
|
2440
2445
|
const idsFrom = entities.map(item => cast(item).id).filter(id => !isNil(id));
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
+
let itemsMiddle;
|
|
2447
|
+
if (idsFrom.length === 0) {
|
|
2448
|
+
itemsMiddle = [];
|
|
2449
|
+
} else {
|
|
2450
|
+
itemsMiddle = await modelTargetMiddle.select({
|
|
2451
|
+
where: {
|
|
2452
|
+
[keyFrom]: idsFrom
|
|
2453
|
+
}
|
|
2454
|
+
}, methodOptionsReal);
|
|
2455
|
+
}
|
|
2446
2456
|
if (optionsReal.groups) {
|
|
2447
2457
|
for (const entity of entities) {
|
|
2448
2458
|
const idsTo = itemsMiddle.filter(item => item[keyFrom] === cast(entity).id).map(item => item[keyTo]);
|
|
@@ -2577,12 +2587,17 @@ let ServiceRelations = (_dec$a = Service(), _dec2$a = BeanInfo({
|
|
|
2577
2587
|
const entity = entities[index];
|
|
2578
2588
|
if (entity[relationName] && entity[relationName].length > 0) {
|
|
2579
2589
|
const idsTo = entity[relationName].map(item => item.id);
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2590
|
+
let itemsMiddle;
|
|
2591
|
+
if (idsTo.length === 0) {
|
|
2592
|
+
itemsMiddle = [];
|
|
2593
|
+
} else {
|
|
2594
|
+
itemsMiddle = await cast(modelTargetMiddle).__select_raw(undefined, {
|
|
2595
|
+
where: {
|
|
2596
|
+
[keyFrom]: cast(entity).id,
|
|
2597
|
+
[keyTo]: idsTo
|
|
2598
|
+
}
|
|
2599
|
+
}, methodOptionsReal);
|
|
2600
|
+
}
|
|
2586
2601
|
for (const child of entity[relationName]) {
|
|
2587
2602
|
const itemMiddle = itemsMiddle.find(item => item[keyTo] === child.id);
|
|
2588
2603
|
if (!itemMiddle) {
|
|
@@ -2835,6 +2850,7 @@ class BeanModelCache extends BeanModelCrud {
|
|
|
2835
2850
|
return result;
|
|
2836
2851
|
}
|
|
2837
2852
|
async mget(ids, options) {
|
|
2853
|
+
if (ids.length === 0) return [];
|
|
2838
2854
|
const items = await this.__mget_raw(undefined, ids, options);
|
|
2839
2855
|
return await this.relations.handleRelationsMany(items, options, options);
|
|
2840
2856
|
}
|