Query<InstanceType extends ManagedObject> class abstract

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();

Constructors

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

Properties

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

Methods

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.
insertMany(List<InstanceType> objects) Future<List<InstanceType>>
Inserts an InstanceTypes 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 nonexistent method or property is accessed.
inherited
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.
inherited
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.

Operators

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

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.