Skip to content

Documentation / @ember-data/legacy-compat / utils / formattedId

Call Signature

ts
function formattedId(id): string;

Defined in: utils.ts:145

Format an id to the format expected by the EmberData Cache. Currently this means that id should be string | null.

Asserts invalid IDs (undefined, '', 0, '0') in dev.

Usage

js
import formattedId from 'client/utils/formatted-id';

formattedId('1'); // => '1'
formattedId(1); // => '1'
formattedId(null); // => null
	```

### Parameters

#### id

the potentially un-normalized id

`string` | `number`

### Returns

`string`

the normalized id

## Call Signature

```ts
function formattedId(id): null;

Defined in: utils.ts:146

Format an id to the format expected by the EmberData Cache. Currently this means that id should be string | null.

Asserts invalid IDs (undefined, '', 0, '0') in dev.

Usage

js
import formattedId from 'client/utils/formatted-id';

formattedId('1'); // => '1'
formattedId(1); // => '1'
formattedId(null); // => null
	```

### Parameters

#### id

`null`

the potentially un-normalized id

### Returns

`null`

the normalized id

## Call Signature

```ts
function formattedId(id): null | string;

Defined in: utils.ts:147

Format an id to the format expected by the EmberData Cache. Currently this means that id should be string | null.

Asserts invalid IDs (undefined, '', 0, '0') in dev.

Usage

js
import formattedId from 'client/utils/formatted-id';

formattedId('1'); // => '1'
formattedId(1); // => '1'
formattedId(null); // => null
	```

### Parameters

#### id

the potentially un-normalized id

`null` | `string` | `number`

### Returns

`null` \| `string`

the normalized id

Released under the MIT License.