QueryBuilder class

A fluent SELECT query builder.

Obtain one via DartApiDB.query (imported from dartapi_db):

final rows = await db.query('users')
    .where('age', greaterThan: 18)
    .where('status', equals: 'active')
    .orderBy('name')
    .limit(20)
    .offset(0)
    .get();

final user = await db.query('users').where('id', equals: id).first();
final total = await db.query('users').where('role', equals: 'admin').count();

Constructors

QueryBuilder(DartApiDB _db, String _table)

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

count() Future<int>
Returns the number of rows matching the current WHERE conditions.
first() Future<Map<String, dynamic>?>
Returns the first matching row, or null if none match.
get() Future<DbResult>
Executes the query and returns all matching rows as a DbResult.
limit(int n) QueryBuilder
Limits the number of rows returned.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
offset(int n) QueryBuilder
Skips the first n matching rows (offset-based pagination).
orderBy(String column, {bool ascending = true}) QueryBuilder
Adds an ORDER BY clause. Call multiple times for multi-column sort.
select(List<String> columns) QueryBuilder
Restricts SELECT to specific columns. Default is *.
toString() String
A string representation of this object.
inherited
where(String column, {Object? equals, Object? notEquals, Object? greaterThan, Object? lessThan, Object? greaterThanOrEqual, Object? lessThanOrEqual, String? like, List<Object?>? whereIn, bool isNull = false, bool isNotNull = false}) QueryBuilder
Adds a WHERE condition. Pass exactly one named argument per call.

Operators

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