---
lang: en
title: 'API docs: repository.flattenmapbykeys'
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.flattenmapbykeys.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/repository](./repository.md) &gt; [flattenMapByKeys](./repository.flattenmapbykeys.md)

## flattenMapByKeys() function

Returns an array of instances from the target map. The order of arrays is based on the order of sourceIds

<b>Signature:</b>

```typescript
export declare function flattenMapByKeys<T>(sourceIds: unknown[], targetMap: Map<unknown, T>): (T | undefined)[];
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  sourceIds | <code>unknown[]</code> | One value or array of values (of the target key) |
|  targetMap | <code>Map&lt;unknown, T&gt;</code> | a map that matches sourceIds with instances |

<b>Returns:</b>

`(T | undefined)[]`


