refParam top-level constant
RefParam
const refParam
When specifying a CollectionModelPath or DocumentModelPath field, you can load the referenced document together by specifying it in the field when referencing other documents.
Use with freezed
, etc.
If this field is present, a ModelRefMixin
is automatically assigned to the document.
CollectionModelPathやDocumentModelPathの各フィールドを指定する際に他のドキュメントを参照するときにフィールドに指定することでその参照ドキュメントを合わせてロードすることができます。
freezed
などと共に利用してください。
このフィールドが存在する場合は、ドキュメントにModelRefMixin
が自動で付与されます。
@freezed
@formValue
@immutable
@CollectionModelPath("shop")
class ShopModel with _$ShopModel {
const factory ShopModel({
@Default("") String name,
@Default("") String description,
ModelRef<UserModel> user,
}) = _ShopModel;
const ShopModel._();
factory ShopModel.fromJson(Map<String, Object?> json) => _$ShopModelFromJson(json);
static const document = _$ShopModelDocumentQuery();
static const collection = _$ShopModelCollectionQuery();
}
Implementation
const refParam = RefParam();