NoSqlDatabase class
Class for building a NoSql database model within an application.
It is based on the Firestore model and handles data separately as documents and collections.
https://firebase.google.com/docs/firestore/data-model
Use loadDocument to read individual data and loadCollection to read a collection of data.
You can pass ModelAdapterDocumentQuery on each data read and specify callbacks when data is updated internally.
This makes it possible to monitor changes that occur elsewhere (or outside the application, such as on the server side) and to handle data in sync with the database.
Data can be added (updated) and deleted only in documents. Use saveDocument and deleteDocument respectively.
Callbacks for onInitialize, onLoad, onSaved, and onDeleted can be passed when an object is created, making it possible to add processing that links with external databases, etc. when data is read or saved.
When a document or collection is destroyed, use removeDocumentListener and removeCollectionListener to remove each document or collection from the monitoring target.
アプリケーション内でのNoSqlデータベースモデルを構築するためのクラスです。
Firestoreのモデルをベースとしており、ドキュメントとコレクションに分けてデータを扱います。
https://firebase.google.com/docs/firestore/data-model
個別のデータの読み取りはloadDocumentを利用し、まとまったデータの読み取りはloadCollectionを利用します。
それぞれのデータ読み取り時にModelAdapterDocumentQueryを渡すことができ、データが内部で更新された場合のコールバックを指定できます。
これにより他の箇所で起きた(もしくはサーバー側などのアプリ外)変更を監視することが可能になりデータベースと同期したデータを扱うことができます。
データの追加(更新)、削除はドキュメントのみで行うことが可能です。それぞれsaveDocument、deleteDocumentで行います。
オブジェクトの作成時にonInitialize、onLoad、onSaved、onDeletedのコールバックを渡すことができ、データの読み出し時や保存時などに外部のデータベース等との連携処理を追加することが可能です。
ドキュメントやコレクションが破棄される際はremoveDocumentListener、removeCollectionListenerで各ドキュメントやコレクションを監視対象から外してください。
Constructors
-
NoSqlDatabase({Future<
void> onInitialize(NoSqlDatabase database)?, Future<void> onLoad(NoSqlDatabase database)?, Future<void> onSaved(NoSqlDatabase database)?, Future<void> onDeleted(NoSqlDatabase database)?, Future<void> onClear(NoSqlDatabase database)?}) - Class for building a NoSql database model within an application.
Properties
- data ↔ DynamicMap
-
Location where real data is stored.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- isInitialValueRegistered → bool
-
Returns
true
if data is registered with setInitialValue.no setter -
onClear
→ Future<
void> Function(NoSqlDatabase database)? -
Executed when all Database is deleted.
final
-
onDeleted
→ Future<
void> Function(NoSqlDatabase database)? -
Executed when Database is deleted.
final
-
onInitialize
→ Future<
void> Function(NoSqlDatabase database)? -
Executed at Database initialization time.
final
-
onLoad
→ Future<
void> Function(NoSqlDatabase database)? -
Executed when loading Database.
final
-
onSaved
→ Future<
void> Function(NoSqlDatabase database)? -
Executed when saving the Database.
final
-
registeredInitialValuePaths
→ List<
String> -
Returns a list of registered initial value paths.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clearAll(
) → Future< void> - Delete all data.
-
deleteDocument(
ModelAdapterDocumentQuery query, {String? prefix}) → Future< void> -
Deletes the data in the document corresponding to
query
by passingquery
. -
getInitialCollection(
ModelAdapterCollectionQuery query, {String? prefix}) → Future< Map< String, DynamicMap> ?> -
Load the document corresponding to
query
from_registeredInitialValue
. -
getInitialDocument(
ModelAdapterDocumentQuery query, {String? prefix}) → Future< DynamicMap?> -
Load the document corresponding to
query
from_registeredInitialValue
. -
loadCollection(
ModelAdapterCollectionQuery query, {String? prefix}) → Future< Map< String, DynamicMap> ?> -
Pass
query
and load the collection corresponding toquery
. -
loadDocument(
ModelAdapterDocumentQuery query, {String? prefix}) → Future< DynamicMap?> -
Pass
query
and load the document corresponding toquery
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyDocuments(
String documentPath, String documentId, DynamicMap value, ModelUpdateNotificationStatus status, ModelAdapterDocumentQuery query) → void -
Sends notifications to monitored documents and collections based on
documentPath
anddocumentId
. -
removeCollectionListener(
ModelAdapterCollectionQuery? query, {String? prefix}) → void -
Pass
query
to remove the collection corresponding toquery
from the monitored list. -
removeDocumentListener(
ModelAdapterDocumentQuery? query, {String? prefix}) → void -
Pass
query
to remove the document corresponding toquery
from the monitored list. -
replace(
DynamicMap replaceData) → Future< void> -
Replaces all data in the database inside by giving
replaceData
. -
saveCollection(
ModelAdapterCollectionQuery query, Map< String, DynamicMap> value, {String? prefix}) → Future<void> -
Update and add data from the collection corresponding to
query
tovalue
by passingquery
. -
saveDocument(
ModelAdapterDocumentQuery query, DynamicMap value, {String? prefix}) → Future< void> -
Update and add data to
value
by passingquery
and the data in the document corresponding toquery
. -
setInitialValue(
String path, DynamicMap value) → void -
Add/update the data of
value
at the position ofpath
. -
syncCollection(
ModelAdapterCollectionQuery query, Map< String, DynamicMap> ? value, {String? prefix}) → Future<Map< String, DynamicMap> ?> -
Stores
value
in the path corresponding toquery
and then returnsvalue
. -
syncDocument(
ModelAdapterDocumentQuery query, DynamicMap? value, {String? prefix}) → Future< DynamicMap?> -
Stores
value
in the path corresponding toquery
and then returnsvalue
. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited