FirestoreModelAdapter class

Model adapter with Firebase Firestore available.

Firestore application settings must be completed in advance and FirebaseCore.initialize must be executed.

Basically, the default FirebaseFirestore.instance is used, but it is possible to use a specified database by passing database when creating the adapter.

You can initialize Firebase by passing options.

In addition, internally retrieved data can be cached, and notifications can be sent to the relevant data for internal changes that occur in DocumentBase.save, DocumentBase.delete, etc., so that changes can be reflected.

The internal database can be specified in localDatabase.

By passing data to initialValue, the database can be used as a data mockup because it contains data in advance.

By adding prefix, all paths can be prefixed, enabling operations such as separating data storage locations for each Flavor.

FirebaseFirestoreを利用できるようにしたモデルアダプター。

事前にFirestoreのアプリ設定を済ませておくこととFirebaseCore.initializeを実行しておきます。

基本的にデフォルトのFirebaseFirestore.instanceが利用されますが、アダプターの作成時にdatabaseを渡すことで指定されたデータベースを利用することが可能です。

optionsを渡すことでFirebaseの初期化を行うことができます。

また、内部で取得したデータをキャッシュしておき、DocumentBase.saveDocumentBase.deleteなどで発生した内部的な変更については関連するデータに通知を送ることができ変更を反映することができます。

内部データベースはlocalDatabaseで指定することができます。

initialValueにデータを渡すことで予めデータが入った状態でデータベースを利用することができるためデータモックとして利用することができます。

prefixを追加することですべてのパスにプレフィックスを付与することができ、Flavorごとにデータの保存場所を分けるなどの運用が可能です。

Inheritance
Implemented types
Implementers

Constructors

FirestoreModelAdapter({List<ModelInitialValue>? initialValue, FirebaseFirestore? database, NoSqlDatabase? localDatabase, FirebaseOptions? options, FirebaseOptions? iosOptions, FirebaseOptions? androidOptions, FirebaseOptions? webOptions, FirebaseOptions? linuxOptions, FirebaseOptions? windowsOptions, FirebaseOptions? macosOptions, String? prefix, DatabaseValidator? validator, Future<void> onInitialize(FirebaseOptions? options)?})
Model adapter with Firebase Firestore available.
const

Properties

androidOptions FirebaseOptions?
Options for initializing Firebase.
final
availableListen bool
no setteroverride
database → FirebaseFirestore
The Firestore database instance used in the adapter.
no setteroverride
hashCode int
The hash code for this object.
no setteroverride
initialValue List<ModelInitialValue>?
Actual data when used as a mock-up.
final
iosOptions FirebaseOptions?
Options for initializing Firebase.
final
linuxOptions FirebaseOptions?
Options for initializing Firebase.
final
localDatabase NoSqlDatabase
Caches data retrieved from the specified internal database, Firestore.
no setter
macosOptions FirebaseOptions?
Options for initializing Firebase.
final
onInitialize → (Future<void> Function(FirebaseOptions? options)?)
Callback for initialization. If this is specified, normal initialization is not performed.
final
options FirebaseOptions?
Options for initializing Firebase.
no setter
prefix String?
Path prefix.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
validator DatabaseValidator?
Specify the permission validator for the database.
final
webOptions FirebaseOptions?
Options for initializing Firebase.
final
windowsOptions FirebaseOptions?
Options for initializing Firebase.
final

Methods

clearAll() Future<void>
Delete all data in the database.
override
clearCache() Future<void>
If the database is taking a local cache, delete it.
override
deleteDocument(ModelAdapterDocumentQuery query) Future<void>
Delete data from the platform set by the adapter by passing query.
override
deleteOnBatch(ModelBatchRef ref, ModelAdapterDocumentQuery query) → void
Describe the data deletion process when performing a batch.
override
deleteOnTransaction(ModelTransactionRef ref, ModelAdapterDocumentQuery query) → void
Describe the data deletion process when performing a transaction.
override
disposeCollection(ModelAdapterCollectionQuery query) → void
The associated collection is discarded by passing query.
override
disposeDocument(ModelAdapterDocumentQuery query) → void
The destruction of related documents is handled by passing query.
override
hasMatch({required String path, required String pattern}) List<String>?
Determines if path matches pattern of the form xxxxx/:id/yyyy.
inherited
listenCollection(ModelAdapterCollectionQuery query) Future<List<StreamSubscription>>
Pass query to monitor the collection.
override
listenDocument(ModelAdapterDocumentQuery query) Future<List<StreamSubscription>>
Pass query to monitor the document.
override
loadAggregation<T>(ModelAdapterCollectionQuery query, ModelAggregateQuery<AsyncAggregateValue> aggregateQuery) Future<T?>
Aggregate queries against data collections to retrieve data.
override
loadCollection(ModelAdapterCollectionQuery query) Future<Map<String, DynamicMap>>
Pass query to the platform set by the adapter to retrieve the collection.
override
loadDocument(ModelAdapterDocumentQuery query) Future<DynamicMap>
Pass query to the platform set by the adapter to retrieve the document.
override
loadOnTransaction(ModelTransactionRef ref, ModelAdapterDocumentQuery query) FutureOr<DynamicMap>
Describe the data acquisition process when performing a transaction.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
runBatch(FutureOr<void> batch(ModelBatchRef ref), int splitLength) FutureOr<void>
Processes a batch for execution.
override
runTransaction(FutureOr<void> transaction(ModelTransactionRef ref)) FutureOr<void>
Do the processing to execute the transaction.
override
saveDocument(ModelAdapterDocumentQuery query, DynamicMap value) Future<void>
By passing the query and the value to be stored, the data is stored on the platform set by the adapter.
override
saveOnBatch(ModelBatchRef ref, ModelAdapterDocumentQuery query, DynamicMap value) → void
Describe the data storage process when performing a batch.
override
saveOnTransaction(ModelTransactionRef ref, ModelAdapterDocumentQuery query, DynamicMap value) → void
Describes the data storage process when performing a transaction.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
override

Static Properties

sharedLocalDatabase NoSqlDatabase
A common internal database throughout the app.
final

Static Methods

registerConverter(FirestoreModelFieldValueConverter converter) → void
A special class can be registered as a ModelFieldValue by passing FirestoreModelFieldValueConverter to converter.
unregisterConverter(FirestoreModelFieldValueConverter converter) → void
By passing FirestoreModelFieldValueConverter to converter, you can release an already registered FirestoreModelFieldValueConverter.