runTransaction method

Future<void> runTransaction({
  1. required AGConnectCloudDBTransaction transaction,
})

This method is called to perform a specified transaction operation.

Comply with the following rules when invoking this method:

  • You can call this method to perform transaction operations only when Cloud DB zone is opened. Otherwise, the transaction fails to be executed.
  • You can call this method to perform transaction operations only when the Cloud DB zone synchronization mode is cache mode.
  • Multiple data operations can be performed in a transaction.
  • The written and deleted object records contained in a transaction must be less than or equal to 1000. Otherwise, the transaction fails to be executed.

Implementation

Future<void> runTransaction({
  required AGConnectCloudDBTransaction transaction,
}) async {
  try {
    return await _methodChannel.invokeMethod<void>(
      _MethodConstants.RUN_TRANSACTION,
      <String, dynamic>{
        _KeyConstants.ZONE_ID: _id,
        _KeyConstants.TRANSACTION_ELEMENTS: transaction.transactionElements,
      },
    );
  } catch (e) {
    throw AGConnectCloudDBException._from(e);
  }
}