executeUpsert method

void executeUpsert({
  1. required String objectTypeName,
  2. required List<Map<String, dynamic>> entries,
})

This method is used to write a group of objects in a transaction to the Cloud DB zone on the cloud in batches. A transaction is atomic. All operations in a transaction will either be successful or fail.

Comply with the following rules when calling this method:

  • The write operation in a transaction must be performed after the query operation.
  • This method can be called to write data only when the network is properly connected.
  • The synchronization property of Cloud DB zone is cache mode.
  • The data size of multiple write and delete operations in a transaction must be less than or equal to 2 MB. Otherwise, the transaction fails.

Implementation

void executeUpsert({
  required String objectTypeName,
  required List<Map<String, dynamic>> entries,
}) {
  if (objectTypeName.isEmpty) {
    throw FormatException(
        'objectTypeName cannot be an empty string.', objectTypeName);
  }
  if (entries.isEmpty) {
    throw FormatException('entries cannot be an empty list.', entries);
  }
  _transactionElements.add(
    <String, dynamic>{
      _TransactionConstants.OPERATION: _TransactionConstants.EXECUTE_UPSERT,
      _TransactionConstants.ZONE_OBJECT_TYPE_NAME: objectTypeName,
      _TransactionConstants.ZONE_OBJECT_DATA_ENTRIES: entries,
    },
  );
}