deleteAll static method

Future<void> deleteAll(
  1. List<ParseObject> objects, {
  2. bool useMasterKey = false,
})

Deletes each object in the provided list from the server.

Implementation

static Future<void> deleteAll(List<ParseObject> objects,
    {bool useMasterKey = false}) async {
  assert(objects.length <= limitBatchOperations,
      'batch operations limit are $limitBatchOperations objects');

  final jsonBody = json.encode({
    'requests': objects
        .map((object) => object._batchDeleteCommand)
        .toList(growable: false)
  });

  final headers = {
    'Content-Type': 'application/json; charset=utf-8',
  };
  final results = await parseHTTPClient.post(
    '${parse.configuration!.uri.path}/batch',
    body: jsonBody,
    headers: headers,
    useMasterKey: useMasterKey,
  );
  if (results is List<dynamic>) {
    for (int i = 0; i < results.length; i++) {
      objects[i]._isDeleted = true;
      objects[i]._reset();
    }
  }
  return;
}