# selection.Selection.oneOrUndefined

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

```
oneOrUndefined(
  criteria?: WhereOf<Model>,
): Model | undefined
```

The single member, or undefined when there is none.

[`one`](/en/ts/latest/reference/selection-selection-one/) without the empty case: several still throws, because that says the
criteria were wrong rather than that the answer is absent.

## Examples

```ts
snapshot.sessions.oneOrUndefined({ name: "work" })?.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 `oneOrUndefined`.

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