mWrite method

Future<Map<String, dynamic>> mWrite(
  1. String index,
  2. String collection,
  3. List<Map<String, dynamic>> documents
)

Creates or replaces large amounts of documents as fast as possible.

Implementation

Future<Map<String, dynamic>> mWrite(String index, String collection,
    List<Map<String, dynamic>> documents) async {
  final response = await kuzzle.query(KuzzleRequest(
    action: 'mWrite',
    collection: collection,
    controller: name,
    index: index,
    body: <String, dynamic>{
      'documents': documents,
    },
  ));

  final result = response.result as Map<String, dynamic>;
  if (result['successes'] is List && result['errors'] is List) {
    return result;
  }

  throw BadResponseFormatError(
      response.error?.id, '$name.exists: bad response format', response);
}