# Collection: delete() method

> The delete() method of the Collection interface deletes an entry and resolves with whether it existed.

The **`delete()`** method of the [`Collection`](/docs/room/collection) interface deletes an entry and resolves with whether it existed.

## Syntax

```ts
delete(id)
delete(id, options)
```

### Parameters

`id`
: The entry's ID.

`options` Optional
: An object with any of these properties:

  `version`
  : The version the entry must have, or the delete fails with `E_VERSION`.

  `once`
  : A key that makes the delete safe to repeat, as for [`PlayerData.set()`](/docs/room/player-data/set).

### Return value

A `Promise` that resolves with `true` if the entry existed, or `false`.

### Exceptions

The promise rejects with a [`DataError`](/docs/room/data-error), such as `E_VERSION` when the entry doesn't have the `version` given.

## Examples

### Clearing a finished game from players' lists

```ts
// game-over.ts
import { defineRoom } from "@irtio/room";

export default defineRoom({
  async onPlayerLeave(room, player) {
    const games = room.collection("games");
    const { entries } = await games.list({ owner: player, where: { room: room.id } });
    for (const entry of entries) await games.delete(entry.id);
  },
});
```

## See also

- [`Collection.put()`](/docs/room/collection/put)
