# selection.Selection.one

- **Module:** selection
- **Package:** libtmux
- **Language:** TypeScript
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ts/blob/073b9d7dedad900bff6f5ec0ea47794e40225870/packages/libtmux/src/selection.ts#L546
- **Page:** https://libtmux.org/en/ts/latest/reference/selection-selection-one/

```
one(criteria?: WhereOf<Model>): Model
```

The single member, or the single one matching `criteria`.

Throws [`NoMatchError`](/en/ts/latest/reference/errors-nomatcherror/) for none and [`MultipleMatchesError`](/en/ts/latest/reference/errors-multiplematcheserror/) for several, so
"exactly one" is enforced rather than assumed — a [`first`](/en/ts/latest/reference/selection-selection-first/) that silently
takes the head of two is how the wrong pane gets driven.

An id is not always one member. A window linked into two sessions, or
shared by two grouped sessions, has a placement in each and both carry the
same id, so [`one`](/en/ts/latest/reference/selection-selection-one/)`({ id })` raises for a perfectly good id. Add the session
to say which placement is meant.

## Examples

```ts
const only = snapshot.sessions.one({ name: "work" });
only.id;
```

## Type parameters

- [`Model`](/en/ts/latest/reference/selection-selection/#selection.Selection.type-parameter.Model), declared by [`Selection<Model>`](/en/ts/latest/reference/selection-selection/)

## Parameters

- `criteria?` (`WhereOf<Model>`)

## Guides

Pages that discuss `one`.

### Concepts

- [Filtering and queries](/en/ts/latest/concepts/queries/)

### Guides

- [Querying and filtering](/en/ts/latest/guides/querying-and-filtering/)
