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.

You can specify a default model adapter by specifying adapter.

You can define access rights to the model by specifying permission or mirrorPermission.

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にパスを定義すると別のパスに同じデータを複製することができます。

adapterを指定することでデフォルトのモデルアダプターを指定することができます。

permissionmirrorPermissionを指定するとモデルへのアクセス権を定義することができます。

それぞれのデータはdocument.mirrorcollection.mirrorで取得でき、同じようにloadsaveができるようになります。

さらにsaveSyncdeleteSyncを利用することで、同期的にデータの保存や削除が行なえます。

フォロー・フォロワーの実装で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, Object? adapter, String? endpoint, List<ModelPermissionQuery>? permission, List<ModelPermissionQuery>? mirrorPermission})
Annotation to create a collection model.
const

Properties

adapter Object?
Specifies the default adapter.
final
endpoint String?
Endpoints for accessing the API.
final
hashCode int
The hash code for this object.
no setterinherited
mirror String?
Path for mirror collection.
final
mirrorPermission List<ModelPermissionQuery>?
List to define permissions for mirror.
final
path String
Path for collection.
final
permission List<ModelPermissionQuery>?
List to define permissions.
final
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