RefParam class
When specifying a CollectionModelPath or DocumentModelPath field, you can load the referenced document together by specifying it in the field when referencing other documents.
Define the class of the document by specifying documentType.
When adapter is specified, you can specify the ModelAdapter of the data to be read.
Use with freezed
, etc.
If this field is present, a ModelRefMixin
is automatically assigned to the document.
CollectionModelPathやDocumentModelPathの各フィールドを指定する際に他のドキュメントを参照するときにフィールドに指定することでその参照ドキュメントを合わせてロードすることができます。
documentTypeを指定してドキュメントのクラスを定義します。
adapterを指定すると、読み込むデータのModelAdapterを指定することができます。
freezed
などと共に利用してください。
このフィールドが存在する場合は、ドキュメントにModelRefMixin
が自動で付与されます。
@freezed
@formValue
@immutable
@CollectionModelPath("shop")
class ShopModel with _$ShopModel {
const factory ShopModel({
@Default("") String name,
@Default("") String description,
@RefParam(UserModelDocument) ModelRef<UserModel> user,
}) = _ShopModel;
const ShopModel._();
factory ShopModel.fromJson(Map<String, Object?> json) => _$ShopModelFromJson(json);
static const document = _$ShopModelDocumentQuery();
static const collection = _$ShopModelCollectionQuery();
}
- Available Extensions
Constructors
- RefParam(Type documentType, {Object? adapter})
-
When specifying a CollectionModelPath or DocumentModelPath field, you can load the referenced document together by specifying it in the field when referencing other documents.
const
Properties
- adapter → Object?
-
Specify the ModelAdapter of the data to be read.
final
- documentType → Type
-
Defines the document type as it is.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
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