ScopeRegistry class
A registry for query scopes and macros.
Scopes allow you to add constraints to queries for a given model. Global scopes are applied to all queries for a model, while local scopes can be applied on a per-query basis.
Macros allow you to add custom methods to the query builder.
Constructors
- ScopeRegistry()
-
Creates a new ScopeRegistry.
factory
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
-
addAdHocScope(
String table, UntypedScope scope) → void - Adds a scope for an ad-hoc table query.
-
addGlobalScope<
T extends OrmEntity> (String identifier, GlobalScopeCallback< T> scope) → void -
Adds a global scope for a model of type
T. -
addGlobalScopeForType(
Type modelType, String identifier, UntypedScope scope) → void -
Adds a global scope for a model of the given
modelType. -
addGlobalScopePattern(
String identifier, UntypedScope scope, {String pattern = '*'}) → void -
Adds a global scope that applies to models matching a
pattern. -
addLocalScope<
T extends OrmEntity> (String name, LocalScopeCallback< T> scope) → void -
Adds a local scope for a model of type
T. -
addLocalScopePattern(
String name, UntypedLocalScope scope, {String pattern = '*'}) → void -
Adds a local scope that applies to models matching a
pattern. -
addMacro(
String name, QueryMacroCallback macro) → void - Adds a macro to the query builder.
-
applyGlobalScopes<
T extends OrmEntity> (Query< T> query) → Query<T> -
Applies all registered global scopes to the given
query. -
callLocalScope<
T extends OrmEntity> (Type modelType, String name, Query< T> query, List<Object?> args) → Query<T> -
Calls a local scope by
nameon the givenquery. -
callMacro<
T extends OrmEntity> (String name, Query< T> query, List<Object?> args) → Query<T> -
Calls a macro by
nameon the givenquery. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerAdHocTableScope(
String name, UntypedScope scope, {String pattern = '*'}) → void - Registers a scope for an ad-hoc table query.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → ScopeRegistry
-
Global template registry.
final
Constants
- adHocScopeKey → const String
- softDeleteScopeIdentifier → const String