saveOnBatch method

  1. @override
void saveOnBatch(
  1. ModelBatchRef ref,
  2. ModelAdapterDocumentQuery query,
  3. DynamicMap value
)
override

Describe the data storage process when performing a batch.

The ModelBatchRef created by runBatch is passed to ref, and query is the query of the target document.

The data to be stored is passed to value.

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

バッチを行う際のデータ保存処理を記述します。

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

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

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

Implementation

@override
void saveOnBatch(
  ModelBatchRef ref,
  ModelAdapterDocumentQuery query,
  DynamicMap value,
) {
  _assert();
  if (ref is! LocalModelBatchRef) {
    throw Exception("[ref] is not [LocalModelBatchRef].");
  }
  ref._batchList.add(() => saveDocument(query, value));
}