ModelRefMapBuilder<TSource, TResult> class
Builder for granting relationships between models and loading data.
The map in ModelRef is processed. The keys of the map are inherited as is.
Define ModelRefLoaderMixin to match the mix-in.
The procedure is;
- Returns a map of ModelRefBase containing only the relation information stored in
TSource
via modelRef. - Generates and returns a mixed-in DocumentBase with ModelRefMixin<TResult> based on DocumentModelQuery via document.
- Save the map of DocumentBase generated via value to
TSource
and return an updatedTSource
.
モデル間のリレーションを付与しデータのロードを行うためのビルダー。
ModelRefのマップを処理します。マップのキーはそのまま引き継がれます。
ModelRefLoaderMixinをミックスインしたときに合わせて定義します。
手順としては
TSource
に保存されているリレーション情報のみ入ったModelRefBaseのマップをmodelRef経由で返します。- DocumentModelQueryを元にModelRefMixin<TResult>をミックスインしたDocumentBaseをdocument経由で生成し返します。
- value経由で生成されたDocumentBaseのマップを
TSource
に保存して、更新したTSource
を返すようにします。
@override
List<ModelRefBuilderBase<StreamModel>> get builder => [
ModelRefMapBuilder(
modelRef: (value) => value.userMap,
document: (query) => UserModelDocument(query),
value: (value, documents) {
return value.copyWith(userMap: documents);
},
)
];
- Inheritance
-
- Object
- ModelRefBuilderBase<
TSource> - ModelRefMapBuilder
- Available Extensions
- Annotations
Constructors
-
ModelRefMapBuilder({required Map<
String, ModelRefBase?> ? modelRef(TSource value), required ModelRefMixin<TResult> document(DocumentModelQuery modelQuery), required TSource value(TSource value, Map<String, ModelRefMixin< documents), ModelAdapter? adapter, ModelAccessQuery? accessQuery, List<TResult> >ModelValidationQuery> ? validationQueries}) -
Builder for granting relationships between models and loading data.
const
Properties
- accessQuery → ModelAccessQuery?
-
ModelAccessQuery for use in the internal model.
final
- adapter → ModelAdapter?
-
Specify a ModelAdapter for use in the internal model.
final
-
document
→ ModelRefMixin<
TResult> Function(DocumentModelQuery modelQuery) -
Callback to generate a DocumentBase that mixes in a ModelRefMixin<TResult> based on a DocumentModelQuery obtained from a ModelRefBase.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
modelRef
→ Map<
String, ModelRefBase?> ? Function(TSource value) -
Callback to retrieve the map of ModelRefBase stored in
TSource
.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
validationQueries
→ List<
ModelValidationQuery> ? -
Specify a list of
ModelValidationQuery
for use in the internal model.final -
value
→ TSource Function(TSource value, Map<
String, ModelRefMixin< documents)TResult> > -
Callback to store the map of ModelRefMixin<TResult> generated in
TSource
.final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited