saveOnTransaction method

  1. @override
void saveOnTransaction(
  1. ModelTransactionRef ref,
  2. ModelAdapterDocumentQuery query,
  3. DynamicMap value
)
override

Describes the data storage process when performing a transaction.

The ModelTransactionRef created by runTransaction is passed to ref and the query of the target document is passed to query.

The data to be stored is passed to value.

Keys with value value of null should be deleted from the database.

トランザクションを行う際のデータ保存処理を記述します。

refrunTransactionで作成したModelTransactionRefが渡され、queryは対象のドキュメントのクエリが渡されます。

valueに保存するデータが渡されます。

valueの値にNullが入っているキーはデータベース上から削除するようにしてください。

Implementation

@override
void saveOnTransaction(
  ModelTransactionRef ref,
  ModelAdapterDocumentQuery query,
  DynamicMap value,
) {
  _assert();
  if (ref is! LocalModelTransactionRef) {
    throw Exception("[ref] is not [LocalModelTransactionRef].");
  }
  ref._transactionList.add(() => saveDocument(query, value));
}