ModelRefListBuilder<TSource, TResult> class

Builder for granting relationships between models and loading data.

Processes a list of ModelRef.

Define ModelRefLoaderMixin to match the mix-in.

The procedure is;

  1. Returns a list of ModelRefBase containing only relationship information stored in TSource via modelRef.
  2. Generates and returns a mixed-in DocumentBase with ModelRefMixin<TResult> based on DocumentModelQuery via document.
  3. Store the list of DocumentBase generated via value in TSource and return an updated TSource.

モデル間のリレーションを付与しデータのロードを行うためのビルダー。

ModelRefのリストを処理します。

ModelRefLoaderMixinをミックスインしたときに合わせて定義します。

手順としては

  1. TSourceに保存されているリレーション情報のみ入ったModelRefBaseのリストをmodelRef経由で返します。
  2. DocumentModelQueryを元にModelRefMixin<TResult>をミックスインしたDocumentBasedocument経由で生成し返します。
  3. value経由で生成されたDocumentBaseのリストをTSourceに保存して、更新したTSourceを返すようにします。
@override
List<ModelRefBuilderBase<StreamModel>> get builder => [
      ModelRefListBuilder(
        modelRef: (value) => value.userList,
        document: (query) => UserModelDocument(query),
        value: (value, documents) {
          return value.copyWith(userList: documents);
        },
      )
    ];
Inheritance
Available Extensions
Annotations

Constructors

ModelRefListBuilder({required Iterable<ModelRefBase?>? modelRef(TSource value), required ModelRefMixin<TResult> document(DocumentModelQuery modelQuery), required TSource value(TSource value, List<ModelRefMixin<TResult>> documents), ModelAdapter? adapter, ModelAccessQuery? accessQuery, List<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 Iterable<ModelRefBase?>? Function(TSource value)
Callback to retrieve a list 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, List<ModelRefMixin<TResult>> documents)
Callback to store the list 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