QueryBuilder<T extends Map<String, dynamic>> class

A builder class that provides a fluent API for constructing database queries.

Constructors

QueryBuilder(DatabaseSDK _sdk, String _tableName)
Creates a new QueryBuilder instance.

Properties

hashCode int
The hash code for this object.
no setterinherited
params QueryParams<T>
Gets the current query parameters
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tableName String
Gets the current table name
no setter

Methods

aggregate(AggregateType type, String field, {String? alias}) QueryBuilder<T>
Adds an aggregate function to the query.
andWhere(void callback(QueryBuilder<T>)) QueryBuilder<T>
Creates an AND where group
avg(String field, {String? alias}) QueryBuilder<T>
Adds an AVG aggregate function to the query.
compute(Map<String, dynamic Function(Map<String, dynamic>)> computations) QueryBuilder<T>
Computes new fields from existing ones.
count(String field, {String? alias}) QueryBuilder<T>
Adds a COUNT aggregate function to the query.
create(T data, [Options? options]) Future<ApiResponse<T>>
Creates a new record.
delete(dynamic id, [Options? options]) Future<ApiResponse<void>>
Deletes a record by ID.
execute([Options? options]) Future<ApiResponse<T>>
Executes the query with optional transforms.
groupBy(List<String> fields) QueryBuilder<T>
Adds a group by clause to the query.
having(String field, WhereOperator operator, dynamic value) QueryBuilder<T>
Adds a having clause to the query for use with group by.
lag(String field, String alias, {List<String>? partitionBy, List<OrderByClause<T>>? orderBy}) QueryBuilder<T>
Helper method for lag window function.
lead(String field, String alias, {List<String>? partitionBy, List<OrderByClause<T>>? orderBy}) QueryBuilder<T>
Helper method for lead window function.
limit(int limit) QueryBuilder<T>
Sets the limit for the query.
max(String field, {String? alias}) QueryBuilder<T>
Adds a MAX aggregate function to the query.
min(String field, {String? alias}) QueryBuilder<T>
Adds a MIN aggregate function to the query.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
offset(int offset) QueryBuilder<T>
Sets the offset for the query.
orderBy(String field, {SortDirection? direction, NullsPosition? nulls}) QueryBuilder<T>
Adds an order by clause to the query.
orWhere(void callback(QueryBuilder<T>)) QueryBuilder<T>
Creates an OR where group
pivot(String column, List<String> values, AggregateOptions<T> aggregate) QueryBuilder<T>
Pivots the result set.
rank(String alias, {List<String>? partitionBy, List<OrderByClause<T>>? orderBy}) QueryBuilder<T>
Helper method for rank window function.
rawExpression(String sql, [List? bindings]) QueryBuilder<T>
Adds a raw SQL expression to the query.
rowNumber(String alias, {List<String>? partitionBy, List<OrderByClause<T>>? orderBy}) QueryBuilder<T>
Helper method for row number window function.
select(List<String> fields) QueryBuilder<T>
Select specific fields from the table
sum(String field, {String? alias}) QueryBuilder<T>
Adds a SUM aggregate function to the query.
toParams() Future<QueryParams<T>>
Gets the query parameters without executing the query.
toString() String
A string representation of this object.
inherited
transform(TransformConfig<T> config) QueryBuilder<T>
Transforms the result set.
update(dynamic id, Map<String, dynamic> data, [Options? options]) Future<ApiResponse<T>>
Updates a record by ID.
where(dynamic fieldOrConditions, [dynamic operatorOrValue, dynamic value]) QueryBuilder<T>
Adds a where clause to the query.
whereBetween(String field, List range) QueryBuilder<T>
Adds a where between clause.
whereExists(QueryBuilder<Map<String, dynamic>> subqueryBuilder(DatabaseSDK)) QueryBuilder<T>
Adds a where exists clause using a subquery
whereExistsJoin(String tableName, String leftField, String rightField, void additionalConditions(QueryBuilder)?) QueryBuilder<T>
Adds a where exists clause with join conditions
whereIn(String field, List values) QueryBuilder<T>
Adds a where in clause.
whereNotIn(String field, List values) QueryBuilder<T>
Adds a where not in clause.
whereNotNull(String field) QueryBuilder<T>
Adds a where not null clause.
whereNull(String field) QueryBuilder<T>
Adds a where null clause.
window(WindowFunctionType type, String alias, {String? field, List<String>? partitionBy, List<OrderByClause<T>>? orderBy, String? frameClause}) QueryBuilder<T>
Adds a window function to the query.
windowAdvanced(WindowFunctionType type, String alias, {String? field, WindowOver<T>? over, List<WhereClause<T>>? filter}) QueryBuilder<T>
Adds an advanced window function to the query. Example:
with_(String name, dynamic queryOrCallback, {List<String>? columns}) QueryBuilder<T>
Adds a CTE to the query.
withRecursive(String name, QueryBuilder<T> initialQuery, QueryBuilder<T> recursiveQuery, {bool? unionAll, List<String>? columns}) QueryBuilder<T>
Adds a recursive CTE to the query. Example:

Operators

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