Skip to main content

Querying

Use safe-finder APIs for filtered reads, explicit result handling, and predictable query composition.

Important: query contract

The current query surface is intentionally split into:
  • static safe-finder reads such as Model.where(...), Model.orderBy(...), Model.get(), and Model.findOneBy(...)
  • static primary-key reads such as Model.find(id)
  • instance collection reads such as new Model().all()
  • eager loading through with(...) and load(...) when explicit relation methods exist
Recommended rule:
  1. use static query helpers for filtered reads
  2. use static find(id) for direct primary-key lookups
  3. use first() or findOneBy(...) for single nullable reads
  4. use get() for hydrated arrays

Notes

  • Keep query functions deterministic in tests by fixing connection and fixture input.
  • Prefer explicit orderBy direction for predictable output.