For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

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:

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:

Last updated