# EntityStore: all() method

> The all() method of the EntityStore interface returns an iterator over the entities of a kind in the client's view.

The **`all()`** method of the [`EntityStore`](/docs/client/entity-store) interface returns an iterator over the entities of a kind in the client's view.

## Syntax

```ts
all(kind)
```

### Parameters

`kind`
: A kind, the object [`entity()`](/docs/room/entity) returned.

### Return value

An iterator over the kind's entities the client holds, each typed as its kind, in the order they entered. It's empty for a kind the client holds none of, a [hidden kind](/docs/room/guides/state-sync#hidden-entities) included.

### Exceptions

None.

## Description

`all()` visits only what the room sends this client, which the room's [interest](/docs/room/guides/state-sync#interest) decides, not every entity of the kind in the room.

Iterate it with `for...of`, or spread it into an array, `[...room.entities.all(kind)]`, to count or sort the entities. The iterator reads the store as it goes, so don't keep one across state updates.

To find one entity, use [`get()`](/docs/client/entity-store/get) rather than searching `all()`.

## Examples

### Drawing a leaderboard of the players in view

Each racer is an entity with a lap count. The client sorts the racers it holds each time a state update arrives.

```ts
// standings.ts
import { connect, defineSchema, entity } from "@irtio/client";

const Racer = entity("racer", { name: "string", laps: "u8" });
const schema = defineSchema({ entities: [Racer] });

const room = await connect("track-2", { schema });

room.addEventListener("update", () => {
  const standings = [...room.entities.all(Racer)].sort((a, b) => b.laps - a.laps);
  for (const [place, racer] of standings.entries()) console.log(`${place + 1}. ${racer.name} (${racer.laps} laps)`);
});
```

## See also

- [`EntityStore.get()`](/docs/client/entity-store/get)
- [`EntityStore.mine()`](/docs/client/entity-store/mine)
- [`Entities.all()`](/docs/room/entities/all), the room's side
- [Interest](/docs/room/guides/state-sync#interest), for which entities the client sees
