@loopback/docs
Version:
Documentation for LoopBack 4
37 lines (24 loc) • 1.39 kB
Markdown
lang: en
title: 'API docs: repository.flattentargetsofonetomanyrelation'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
editurl: https://github.com/strongloop/loopback-next/tree/master/packages/repository
permalink: /doc/en/lb4/apidocs.repository.flattentargetsofonetomanyrelation.html
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/repository](./repository.md) > [flattenTargetsOfOneToManyRelation](./repository.flattentargetsofonetomanyrelation.md)
## flattenTargetsOfOneToManyRelation() function
Returns an array of instances. The order of arrays is based on as a result of one to many relation. The order of arrays is based on the order of sourceIds
<b>Signature:</b>
```typescript
export declare function flattenTargetsOfOneToManyRelation<Target extends Entity>(sourceIds: unknown[], targetEntities: Target[], targetKey: StringKeyOf<Target>): (Target[] | undefined)[];
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| sourceIds | <code>unknown[]</code> | One value or array of values of the target key |
| targetEntities | <code>Target[]</code> | target entities that satisfy targetKey's value (ids). |
| targetKey | <code>StringKeyOf<Target></code> | name of the target key |
<b>Returns:</b>
`(Target[] | undefined)[]`