modify method

  1. @override
Future<Map<String, dynamic>> modify(
  1. String id,
  2. Map data, [
  3. Map? params
])

Modifies a resource.

Implementation

@override
Future<Map<String, dynamic>> modify(String id, Map data,
    [Map? params]) async {
  var d = _serialize(data);

  if (d is Map && d.containsKey('id')) {
    try {
      await read(d['id'], params);
    } on AngelHttpException catch (e) {
      if (e.statusCode == 404) {
        return await create(data, params);
      } else {
        rethrow;
      }
    }
  }

  var query = buildQuery(table.get(id.toString()), params ?? {}).update(d);
  await _sendQuery(query);
  return await read(id, params);
}