DocumentModelPath class
Annotation for creating a documentation model.
Specify the path for the document 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 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
and can be loaded
and 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()
にドキュメントモデルを取得するためのクエリを定義できます。
mirrorにパスを定義すると別のパスに同じデータを複製することができます。
adapterを指定することでデフォルトのモデルアダプターを指定することができます。
permissionやmirrorPermissionを指定するとモデルへのアクセス権を定義することができます。
それぞれのデータはdocument.mirror
で取得でき、同じようにload
やsave
ができるようになります。
さらにsaveSync
やdeleteSync
を利用することで、同期的にデータの保存や削除が行なえます。
フォロー・フォロワーの実装でNoSQLデータベースにおけるリレーションを実現するために利用することが可能です。
@freezed
@formValue
@immutable
@DocumentModelPath("user/doc")
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();
}
- Available Extensions
Constructors
-
DocumentModelPath(String path, {String? mirror, Object? adapter, String? endpoint, List<
ModelPermissionQuery> ? permission, List<ModelPermissionQuery> ? mirrorPermission}) -
Annotation for creating a documentation 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 documents.
final
-
mirrorPermission
→ List<
ModelPermissionQuery> ? -
List to define permissions for mirror.
final
- path → String
-
Path for documentation.
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