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

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/repository](./repository.md) &gt; [buildLookupMap](./repository.buildlookupmap.md)

## buildLookupMap() function

Returns a map which maps key values(ids) to instances. The instances can be grouped by different strategies.

**Signature:**

```typescript
export declare function buildLookupMap<Key, InType extends object, OutType = InType>(list: InType[], keyName: StringKeyOf<InType>, reducer: (accumulator: OutType | undefined, current: InType) => OutType): Map<Key, OutType>;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  list | InType\[\] | an array of instances |
|  keyName | [StringKeyOf](./repository.stringkeyof.md)<!-- -->&lt;InType&gt; | key name of the source |
|  reducer | (accumulator: OutType \| undefined, current: InType) =&gt; OutType | a strategy to reduce inputs to single item or array |

**Returns:**

Map&lt;Key, OutType&gt;


