* Maps nested FKs from `[1, 2, 3]` to `[1, [2, 3]]`.
(
fk: Primary<any>[],
prop: EntityProperty,
fieldNames = prop.fieldNames,
idx = 0,
)
| 604 | * Maps nested FKs from `[1, 2, 3]` to `[1, [2, 3]]`. |
| 605 | */ |
| 606 | static mapFlatCompositePrimaryKey( |
| 607 | fk: Primary<any>[], |
| 608 | prop: EntityProperty, |
| 609 | fieldNames = prop.fieldNames, |
| 610 | idx = 0, |
| 611 | ): Primary<any> | Primary<any>[] { |
| 612 | if (!prop.targetMeta) { |
| 613 | return fk[idx++]; |
| 614 | } |
| 615 | |
| 616 | const parts: Primary<any>[] = []; |
| 617 | |
| 618 | for (const pk of prop.targetMeta.getPrimaryProps()) { |
| 619 | parts.push(this.mapFlatCompositePrimaryKey(fk, pk, fieldNames, idx)); |
| 620 | idx += pk.fieldNames.length; |
| 621 | } |
| 622 | |
| 623 | if (parts.length < 2) { |
| 624 | return parts[0]; |
| 625 | } |
| 626 | |
| 627 | return parts; |
| 628 | } |
| 629 | |
| 630 | static getPrimaryKeyCondFromArray<T extends object>( |
| 631 | pks: Primary<T>[], |
no test coverage detected