---
lang: en
title: 'API docs: repository.flattenmapbykeys'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/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 | unknown\[\] | One value or array of values (of the target key) |
|  targetMap | Map&lt;unknown, T&gt; | a map that matches sourceIds with instances |

<b>Returns:</b>

(T \| undefined)\[\]


