CollectionModelPath class
Annotation to create a collection model.
Specify the path for the collection in path.
Use with freezed
, etc.
You can define a query to get the document model in static const document = _$(class name)DocumentQuery()
.
You can define a query to retrieve the collection model in static const collection = _$(class name)CollectionQuery()
.
You can duplicate the same data to another path by defining a path in mirror.
Each data can be retrieved with document.mirror
or collection.mirror
and can be loaded
or saved
in the same way.
In addition, by using saveSync
and deleteSync
, data can be saved and deleted synchronously.
It can be used to achieve relationships in NoSQL databases with follow/follow implementations.
コレクションモデルを作成するためのアノテーション。
pathにコレクション用のパスを指定します。
freezed
などと共に利用してください。
static const document = _$(クラス名)DocumentQuery()
にドキュメントモデルを取得するためのクエリを定義できます。
static const collection = _$(クラス名)CollectionQuery()
にコレクションモデルを取得するためのクエリを定義できます。
mirrorにパスを定義すると別のパスに同じデータを複製することができます。
それぞれのデータはdocument.mirror
やcollection.mirror
で取得でき、同じようにload
やsave
ができるようになります。
さらにsaveSync
やdeleteSync
を利用することで、同期的にデータの保存や削除が行なえます。
フォロー・フォロワーの実装でNoSQLデータベースにおけるリレーションを実現するために利用することが可能です。
@freezed
@formValue
@immutable
@CollectionModelPath("user")
class UserModel with _$UserModel {
const factory UserModel({
@Default("") String name,
@Default("") String description,
}) = _UserModel;
const UserModel._();
factory UserModel.fromJson(Map<String, Object?> json) => _$UserModelFromJson(json);
static const document = _$UserModelDocumentQuery();
static const collection = _$UserModelCollectionQuery();
}
- Available Extensions
Constructors
- CollectionModelPath(String path, {String? mirror})
-
Annotation to create a collection model.
const
Properties
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