executeDelete method

Future<int> executeDelete(
  1. {required String objectTypeName,
  2. required List<Map<String, dynamic>> entries}
)

You can call this method to delete a group of Cloud DB zone objects whose primary key values are the same as those of the input object list in batches. The delete operation focuses only on whether the primary key of the object is consistent, regardless of whether other attributes of the object match the stored data. The delete operation is atomic. That is, the input object list is either all deleted successfully or all fails to be deleted.

Returns the number of objects that are successfully deleted.

Comply with the following rules when invoking this method:

  • You can call this method to delete objects only when Cloud DB zone is opened. Otherwise, the delete operation fails.
  • When a group of objects is deleted, the total number of data records in the list must be less than or equal to 1000. Otherwise, the delete operation fails.
  • The data size of all objects in the list must be less than or equal to 2 MB. Otherwise, the delete operation fails.
  • The data size of all objects in the list must be less than or equal to 2 MB only when the data synchronization attribute is cache and the data persistency attribute is non-persistent.

Implementation

Future<int> executeDelete({
  required String objectTypeName,
  required List<Map<String, dynamic>> entries,
}) async {
  if (objectTypeName.isEmpty) {
    throw FormatException(
        'objectTypeName cannot be an empty string.', objectTypeName);
  }
  if (entries.isEmpty) {
    throw FormatException('entries cannot be an empty list.', entries);
  }
  try {
    final int? result = await _methodChannel.invokeMethod<int?>(
      _MethodConstants.EXECUTE_DELETE,
      <String, dynamic>{
        _KeyConstants.ZONE_ID: _id,
        _KeyConstants.ZONE_OBJECT_TYPE_NAME: objectTypeName,
        _KeyConstants.ZONE_OBJECT_DATA_ENTRIES: entries,
      },
    );
    return result!;
  } catch (e) {
    throw AGConnectCloudDBException._from(e);
  }
}