PhormQuery<T extends Model> class

A fluent query builder for PHORM models. Allows chaining conditions, sorting, and pagination.

Constructors

PhormQuery(PhormCore<T> service)
Creates a query bound to service.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
service PhormCore<T>
The service the query executes against.
final

Methods

after(T last) PhormQuery<T>
Keyset (cursor) pagination: returns rows strictly after last in the current orderBy ordering.
attributes(Attributes attr) PhormQuery<T>
Selects specific columns.
avg(Object column) Future<num>
Calculates the average of a specific column.
count({Object? column}) Future<int>
Executes the query and returns the total count of matching rows.
distinct() PhormQuery<T>
Deduplicates result rows (SELECT DISTINCT).
first() Future<T?>
Executes the query and returns the first result, or null.
get() Future<List<T>>
Executes the query and returns a list of models.
getWithCount() Future<ResultWithCount<T>>
Executes the query and returns both the current page of results and the total count.
groupBy(List<Object> columns) PhormQuery<T>
Groups rows by the given columns (GROUP BY).
having(PhormCondition condition) PhormQuery<T>
Adds a HAVING condition for a groupBy query.
include(List<Includable> relations) PhormQuery<T>
Eager-loads relationships.
includeOne(Includable relation) PhormQuery<T>
Eager-loads a single relationship.
limit(int count) PhormQuery<T>
Sets the max results.
max(Object column) Future<num>
Finds the maximum value of a specific column.
min(Object column) Future<num>
Finds the minimum value of a specific column.
noLimit() PhormQuery<T>
Removes the default limit of 20 rows — the query returns all matches.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
offset(int count) PhormQuery<T>
Sets the number of rows to skip.
orderBy(PhormColumn column, {bool descending = false}) PhormQuery<T>
Adds an ORDER BY clause.
rows() Future<List<Map<String, Object?>>>
Executes the query and returns raw rows without model mapping.
select(List<Object> columns) PhormQuery<T>
Selects only the given columns (shorthand for attributes(Attributes.include([...]))).
sum(Object column) Future<num>
Calculates the sum of a specific column.
toSql() String
Compiles and returns the SQL string for this query.
toString() String
A string representation of this object.
inherited
where(PhormCondition condition) PhormQuery<T>
Adds a condition to the query.
whereIf(bool flag, PhormCondition conditionBuilder()) PhormQuery<T>
Adds a condition to the query only if the provided boolean flag is true.
whereNotNull<V>(V? value, PhormCondition conditionBuilder(V value)) PhormQuery<T>
Adds a condition to the query only if the provided value is not null.
withDeleted() PhormQuery<T>
Includes soft-deleted records.

Operators

operator ==(Object other) bool
The equality operator.
inherited