TableManagerState<$Database extends GeneratedDatabase, $Table extends Table, $Dataclass, $FilterComposer extends Composer<$Database, $Table>, $OrderingComposer extends Composer<$Database, $Table>, $ComputedFieldComposer extends Composer<$Database, $Table>, $CreateCompanionCallback extends Function, $UpdateCompanionCallback extends Function, $DataclassWithReferences, $ActiveDataclass, $CreatePrefetchHooksCallback extends Function> class

Defines a class that holds the state for a BaseTableManager

It holds the state for manager of $Table table in $Database database. It holds the $FilterComposer Filters and $OrderingComposer Orderings and $ComputedFieldComposer ComputedFields for the manager.

There are 3 Dataclass generics:

  • $Dataclass is the dataclass that is used to interact with the table
  • $DataclassWithReferences is the dataclass that is returned when the manager is used with the withReferences method, this contains the dataclass and any referenced dataclasses
  • $ActiveDataclass is the dataclass that is returned when the manager is used, this is either $Dataclass or $DataclassWithReferences, depending if the manager has had the withReferences method called on it

It also holds the $CreateCompanionCallback and $UpdateCompanionCallback functions that are used to create companion builders for inserting and updating data. E.G Instead of CategoriesCompanion.insert(name: "School") you would use (f) => f(name: "School")

The $CreatePrefetchHooksCallback refers to the function which the user will use to create a PrefetchHooks in withReferences See the BaseReferences class for more information on how this is used.

E.G.

users.withReferences((prefetch) => prefetch(group: true))
Annotations
  • @immutable

Constructors

TableManagerState({required $Database db, required $Table table, required $FilterComposer createFilteringComposer(), required $OrderingComposer createOrderingComposer(), required $ComputedFieldComposer createComputedFieldComposer(), required $CreateCompanionCallback createCompanionCallback, required $UpdateCompanionCallback updateCompanionCallback, required List<$DataclassWithReferences> withReferenceMapper(List<TypedResult>), required $CreatePrefetchHooksCallback? prefetchHooksCallback, PrefetchHooks? prefetchHooks, List<TypedResult>? prefetchedData, Expression<bool>? filter, bool? distinct, int? limit, int? offset, Set<Expression<Object>> addedColumns = const {}, Set<OrderingBuilder> orderingBuilders = const {}, Set<JoinBuilder> joinBuilders = const {}})
Defines a class which holds the state for a table manager It contains the database instance, the table instance, and any filters/orderings that will be applied to the query This is held in a separate class than the BaseTableManager so that the state can be passed down from the root manager to the lower level managers

Properties

addedColumns Set<Expression<Object>>
Additional columns/expression that will be added to the query with computed fields
final
createComputedFieldComposer → $ComputedFieldComposer Function()
The callback that will be used to create the composer which will be used to create computed fields for the query
final
createFilteringComposer → $FilterComposer Function()
The FilterComposer for this TableManagerState This class will be used to create filtering Expressions which will be applied to the statement when its eventually created
final
createOrderingComposer → $OrderingComposer Function()
The OrderingComposer for this TableManagerState This class will be used to create OrderingTerms which will be applied to the statement when its eventually created
final
db → $Database
The database used to run the query.
final
distinct bool?
Whether the query should return distinct results
final
filter Expression<bool>?
The expression that will be applied to the query
final
hashCode int
The hash code for this object.
no setterinherited
joinBuilders Set<JoinBuilder>
A set of JoinBuilder which will be used to create Joins that will be applied to the build statement
final
limit int?
If set, the maximum number of rows that will be returned
final
offset int?
If set, the number of rows that will be skipped
final
orderingBuilders Set<OrderingBuilder>
A set of OrderingBuilder which will be used to apply OrderingTerms to the statement when it's eventually built
final
prefetchedData List<$ActiveDataclass>?
Prefetched data, if references with prefetching enabled were added to this manager
no setter
prefetchHooks PrefetchHooks
Once withReferences is called, this field will be set to the function that will be used to get the prefetched data
latefinal
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
table → $Table
The table that the manager is for
final

Methods

buildDeleteStatement() DeleteStatement<Table, dynamic>
Build a delete statement based on the manager state
buildSelectStatement({Iterable<Expression<Object>>? targetColumns}) JoinedSelectStatement<$Table, $Dataclass>
Builds a select statement with the given target columns, or all columns if none are provided
buildUpdateStatement() UpdateStatement<$Table, $Dataclass>
Build an update statement based on the manager state
copyWith({bool? distinct, int? limit, int? offset, Expression<bool>? filter, Set<OrderingBuilder>? orderingBuilders, Set<JoinBuilder>? joinBuilders, List<$Dataclass>? prefetchedData, PrefetchHooks? prefetchHooks, Set<Expression<Object>>? addedColumns}) TableManagerState<$Database, $Table, $Dataclass, $FilterComposer, $OrderingComposer, $ComputedFieldComposer, $CreateCompanionCallback, $UpdateCompanionCallback, $DataclassWithReferences, $ActiveDataclass, $CreatePrefetchHooksCallback>
Copy this state with the given values
copyWithActiveDataclass() TableManagerState<$Database, $Table, $Dataclass, $FilterComposer, $OrderingComposer, $ComputedFieldComposer, $CreateCompanionCallback, $UpdateCompanionCallback, $DataclassWithReferences, $DataclassWithReferences, $CreatePrefetchHooksCallback>
When a user calls withReferences on a manager, we return a copy which is set to return a $DataclassWithReferences instead of just a $Dataclass
count() Future<int>
Count the number of rows that would be returned by the built statement
exists() Future<bool>
Check if any rows exists using the built statement
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toActiveDataclass(List<TypedResult> items) List<$ActiveDataclass>
This function is used to ensure that the correct dataclass type is returned by the manager.
toString() String
A string representation of this object.
inherited
withJoin({required Table currentTable, required Table referencedTable, required GeneratedColumn<Object> currentColumn, required GeneratedColumn<Object> referencedColumn}) TableManagerState<$Database, $Table, $Dataclass, $FilterComposer, $OrderingComposer, $ComputedFieldComposer, $CreateCompanionCallback, $UpdateCompanionCallback, $DataclassWithReferences, $ActiveDataclass, $CreatePrefetchHooksCallback>
This method creates a copy of this manager state with a join added to the query.

Operators

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