> 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.md).

# Database Interaction Strategies

SoapJS gives you several ways to query — from simple typed conditions to raw native queries. Pick the lightest one that expresses your need:

1. **Advanced Query Composition with the Where Builder** **Introduction:** Compose type-safe, storage-agnostic conditions (`valueOf().isEq()`, `and`/`or`, `brackets`) inside typed repository methods. Your default for most queries.
2. **Reusable Queries with RepositoryQuery** **Introduction:** Wrap complex or reused queries in named `RepositoryQuery` objects whose `build()` returns portable `FindParams` — query logic as first-class, testable units.
3. **Dedicated Repository Methods** **Introduction:** Expose intent-revealing methods (`findThreats()`) on the repository, keeping call sites clean and the query in one place.
4. **Native Queries** **Introduction:** For queries the abstraction can't express (aggregations, vendor operators, raw SQL), drop to `Source.native()` — kept named and quarantined in a `RepositoryQuery`, never smuggled through casts.

The progression goes composed conditions → reusable query objects → repository abstraction → raw native execution: increasing power, decreasing portability.
