ModelQueryBuilder (Type-Safe)
The ModelQueryBuilder is the primary, partially type-safe query API for Hysteria ORM models. All calls to User.query(), Post.query(), etc., return a ModelQueryBuilder instance.
The query builder is partially type safe, triggering intellisense for developer experience but still allowing the developer to write whatever he wants.
The ModelQueryBuilder by default returns a ModelWithoutRelations<T> type, which is a type that does not have any relations. You can add Relations or Annotations using the load and annotate methods.
Key Features
- Partially type-safe queries and results
- Decorator and relation support
- Rich API for filtering, selecting, joining, and more
- Supports advanced features like CTEs, annotations, pagination, and soft deletes
- Model columns are parsed to database columns based on the case convention of the model, this applies both on column names like
isActiveand on table.column scenarios likeusers.isActive
Example Usage
const users = await User.query().where('status', 'active').many();