transaction method

ModelTransactionCollectionBuilder<TModel> transaction()

Builder for transactions.

ModelTransactionDocument can be created from other DocumentBase using ModelTransactionRef.read, and the process to be executed together can be written.

ModelTransactionDocument.load, ModelTransactionDocument.save, and ModelTransactionDocument.delete using ModelTransactionDocument. transaction processing can be performed by executing

トランザクションを行うためのビルダー。

ModelTransactionRef.readを用いて他のDocumentBaseからModelTransactionDocumentを作成することができ、まとめて実行する処理を記述することができます。

ModelTransactionDocumentを用いてModelTransactionDocument.loadModelTransactionDocument.saveModelTransactionDocument.deleteを実行することでトランザクション処理を行うことが可能です。

final transaction = sourceCollection.transaction();
transaction((ref, collection){
  final doc = ref.read(collection.create()); // `doc` is [ModelTransactionDocument] of `sourceDocument`.
  final newValue = {"name": "test"}; // The same mechanism can be used to perform the same preservation method as usual.
  doc.save(newValue);
});

Implementation

ModelTransactionCollectionBuilder<TModel> transaction() {
  return ModelTransactionCollectionBuilder._(this);
}