#

API Docs for: v3.16.0-alpha.2
Show: Inherited Protected Private Deprecated

# IdentityMap Class

Defined in: `../store/addon/-private/system/identity-map.ts:8`
Module: @ember-data/store

`IdentityMap` is a custom storage map for records by modelName used by `Store`.

- Index
- Methods

## Item Index

### Methods

- clear
- errorsArrayToHash
- errorsHashToArray
- flushPendingSave
- retrieve

## Methods

### `clear`

()

Defined in `../store/addon/-private/system/identity-map.ts:37`

Clears the contents of all known `RecordMaps`, but does not remove the InternalModelMap instances.

### `errorsArrayToHash`

(

- `errors`

)
Object public

Defined in `../store/addon/-private/system/errors-utils.js:78`

Convert an array of errors in JSON-API format into an object.

    import DS from 'ember-data';

    const { errorsArrayToHash } = DS;

    let errorsArray = [
      {
        title: 'Invalid Attribute',
        detail: 'Must be present',
        source: { pointer: '/data/attributes/name' }
      },
      {
        title: 'Invalid Attribute',
        detail: 'Must be present',
        source: { pointer: '/data/attributes/age' }
      },
      {
        title: 'Invalid Attribute',
        detail: 'Must be a number',
        source: { pointer: '/data/attributes/age' }
      }
    ];

    let errors = errorsArrayToHash(errorsArray);
    // {
    //   "name": ["Must be present"],
    //   "age":  ["Must be present", "must be a number"]
    // }

#### Parameters:

- `errors` Array

  array of errors in JSON-API format

#### Returns:

Object:

### `errorsHashToArray`

(

- `errors`

)
Array public

Defined in `../store/addon/-private/system/errors-utils.js:12`

Convert an hash of errors into an array with errors in JSON-API format.

    import DS from 'ember-data';
    const { errorsHashToArray } = DS;
    let errors = {
     base: 'Invalid attributes on saving this record',
     name: 'Must be present',
     age: ['Must be present', 'Must be a number']
    };
    let errorsArray = errorsHashToArray(errors);
    // [
    //   {
    //     title: "Invalid Document",
    //     detail: "Invalid attributes on saving this record",
    //     source: { pointer: "/data" }
    //   },
    //   {
    //     title: "Invalid Attribute",
    //     detail: "Must be present",
    //     source: { pointer: "/data/attributes/name" }
    //   },
    //   {
    //     title: "Invalid Attribute",
    //     detail: "Must be present",
    //     source: { pointer: "/data/attributes/age" }
    //   },
    //   {
    //     title: "Invalid Attribute",
    //     detail: "Must be a number",
    //     source: { pointer: "/data/attributes/age" }
    //   }
    // ]

#### Parameters:

- `errors` Object

  hash with errors as properties

#### Returns:

Array:

array of errors in JSON-API format

### `flushPendingSave`

() private

Defined in `../store/addon/-private/system/fetch-manager.ts:149`

This method is called at the end of the run loop, and flushes any records passed into `scheduleSave`

### `retrieve`

(

- `modelName`

)
InternalModelMap

Defined in `../store/addon/-private/system/identity-map.ts:18`

Retrieves the `InternalModelMap` for a given modelName, creating one if one did not already exist. This is similar to `getWithDefault` or `get` on a `MapWithDefault`

#### Parameters:

- `modelName` Object

  a previously normalized modelName

#### Returns:

InternalModelMap:

the InternalModelMap for the given modelName