save method

Future<Map<String, dynamic>> save(
  1. dynamic data,
  2. {bool waitForSync,
  3. bool silent,
  4. bool returnNew}
)

Implementation

Future<Map<String, dynamic>> save(
  dynamic data, {
  bool waitForSync,
  bool silent,
  bool returnNew,
}) async {
  final queries = <String, String>{
    if (waitForSync != null) 'waitForSync': waitForSync.toString(),
    if (silent != null) 'silent': silent.toString(),
    if (returnNew != null) 'returnNew': returnNew.toString(),
    'collection': name,
  };

  if (_connection.arangoMajor <= 2) {
    final resp = await _connection.request(
      method: 'POST',
      path: '/_api/document',
      body: data,
      queries: queries,
    );
    return resp.body;
  }

  final resp = await _connection.request(
    method: 'POST',
    path: '/_api/document/$name',
    body: data,
    queries: queries,
  );

  return resp.body;
}