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(), andModel.findOneBy(...) - static primary-key reads such as
Model.find(id) - instance collection reads such as
new Model().all() - eager loading through
with(...)andload(...)when explicit relation methods exist
- use static query helpers for filtered reads
- use static
find(id)for direct primary-key lookups - use
first()orfindOneBy(...)for single nullable reads - use
get()for hydrated arrays
Notes
- Keep query functions deterministic in tests by fixing connection and fixture input.
- Prefer explicit
orderBydirection for predictable output.