> For the complete documentation index, see [llms.txt](https://docs.soapjs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.soapjs.com/examples/database-interaction-strategies/using-where-conditions.md).

# Using Where Conditions

The `Where` builder composes **storage-agnostic** conditions — no database syntax in your code. The Source translates a `Where` into the underlying query (e.g. a MongoDB filter), so swapping databases doesn't touch your repository.

```typescript
import { Where, FindParams } from '@soapjs/soap';

const where = new Where()
  .valueOf('universe').isEq('marvel')
  .and.valueOf('alignment').isIn(['villain', 'anti-hero']);

await repo.find(FindParams.create({ where, sort: { name: 1 }, limit: 20 }));
```

### Operators

* equality: `isEq` / `isNotEq`
* ranges: `isLt` `isLte` `isGt` `isGte`
* membership: `isIn` / `isNotIn`
* pattern: `like`
* logical: `and` · `or` · grouping: `brackets(w => ...)`

### Grouping with brackets

Use `brackets` for precedence — e.g. a text search across two fields, AND a universe:

```typescript
const where = new Where()
  .valueOf('universe').isEq('marvel')
  .and.brackets(w => w.valueOf('name').like(q).or.valueOf('alias').like(q));
```

Inside a repository method this keeps the adapter free of any Mongo/SQL syntax:

```typescript
async findAll(filters: CharacterFilters): Promise<Result<Character[]>> {
  const where = new Where();
  if (filters.universe) where.valueOf('universe').isEq(filters.universe);
  return this.find(FindParams.create({ where }));
}
```
