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 == null || objectTypeName.isEmpty) {
    throw FormatException('Value of objectTypeName cannot be null or an empty string.', objectTypeName);
  }
  if (entries == null || entries.isEmpty) {
    throw FormatException('Value of entries cannot be null or an empty string.', entries);
  }

  _transactionElements.add(
    <String, dynamic>{
      TransactionConstants.OPERATION: TransactionConstants.EXECUTE_UPSERT,
      TransactionConstants.ZONE_OBJECT_TYPE_NAME: objectTypeName,
      TransactionConstants.ZONE_OBJECT_DATA_ENTRIES: entries,
    },
  );
}