replace method

Future<Map<String, dynamic>> replace(
  1. String documentHandle,
  2. Map<String, dynamic> newValue,
  3. {String rev,
  4. bool waitForSync,
  5. bool silent,
  6. bool returnNew,
  7. bool returnOld}
)

Implementation

Future<Map<String, dynamic>> replace(
  String documentHandle,
  Map<String, dynamic> newValue, {
  String rev,
  bool waitForSync,
  bool silent,
  bool returnNew,
  bool returnOld,
}) async {
  final headers = <String, String>{};
  if (rev != null && _connection.arangoMajor >= 3) {
    headers['if-match'] = rev;
  }

  final queries = <String, String>{};
  if (waitForSync == true) queries['waitForSync'] = 'true';
  if (silent == true) queries['silent'] = 'true';
  if (returnNew == true) queries['returnNew'] = 'true';
  if (returnOld == true) queries['returnOld'] = 'true';

  final resp = await _connection.request(
    method: 'PUT',
    path: '/_api/${_documentPath(documentHandle)}',
    body: newValue,
    queries: queries,
    headers: headers,
  );
  return resp.body;
}