Query<InstanceType extends ManagedObject> class Null safety

An object for configuring and executing a database query.

Queries are used to fetch, update, insert, delete and count InstanceTypes in a database. InstanceType must be a ManagedObject.

    final query = Query<Employee>()
      ..where((e) => e.salary).greaterThan(50000);
    final employees = await query.fetch();


Query(ManagedContext context, {InstanceType? values})
Creates a new Query.
Query.forEntity(ManagedEntity entity, ManagedContext context)
Creates a new Query without a static type.


canModifyAllInstances bool?
Confirms that a query has no predicate before executing it.
read / write
context ManagedContext
The ManagedContext this query will be executed on.
entity ManagedEntity
The ManagedEntity of the InstanceType.
fetchLimit int?
Limits the number of objects returned from the Query.
read / write
hashCode int
The hash code for this object.
offset int?
Offsets the rows returned.
read / write
predicate QueryPredicate?
A predicate for filtering the result or operation set.
read / write
reduce QueryReduceOperation<InstanceType>
Returns a new object that can execute functions like sum, average, maximum, etc.
runtimeType Type
A representation of the runtime type of the object.
timeoutInSeconds int?
Number of seconds before a Query times out.
read / write
valueMap Map<String, dynamic>?
Values to be used when inserting or updating an object.
read / write
values ↔ InstanceType?
Values to be sent to database during an update or insert query.
read / write


delete() Future<int>
Deletes InstanceTypes from the underlying database.
fetch() Future<List<InstanceType>>
Fetches InstanceTypes from the database.
fetchOne() Future<InstanceType?>
Fetches a single InstanceType from the database.
insert() Future<InstanceType>
Inserts an InstanceType into the underlying database.
join<T extends ManagedObject>({T object(InstanceType x), ManagedSet<T> set(InstanceType x)}) Query<T>
Configures this instance to fetch a relationship property identified by object or set.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
pageBy<T>(T propertyIdentifier(InstanceType x), QuerySortOrder order, {T boundingValue}) → void
Configures this instance to fetch a section of a larger result set.
returningProperties(List propertyIdentifiers(InstanceType x)) → void
Configures the list of properties to be fetched for InstanceType.
sortBy<T>(T propertyIdentifier(InstanceType x), QuerySortOrder order) → void
Configures this instance to sort its results by some property and order.
toString() String
A string representation of this object.
update() Future<List<InstanceType>>
Updates InstanceTypes in the underlying database.
updateOne() Future<InstanceType?>
Updates an InstanceType in the underlying database.
where<T>(T propertyIdentifier(InstanceType x)) QueryExpression<T, InstanceType>
Selects a property from the object being queried to add a filtering expression.


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

Static Methods

insertObject<T extends ManagedObject>(ManagedContext context, T object) Future<T>
Inserts a single object into the database managed by context.
insertObjects<T extends ManagedObject>(ManagedContext context, List<T> objects) Future<List<T>>
Inserts each object in objects into the database managed by context in a single transaction.