remove method
Removes the given resource.
Implementation
@override
Future<Map<String, dynamic>> remove(String id,
[Map<String, dynamic>? params]) async {
if (id == 'null') {
// Remove everything...
if (!(allowRemoveAll == true ||
params?.containsKey('provider') != true)) {
throw AngelHttpException.forbidden(
message: 'Clients are not allowed to delete all items.');
} else {
await collection.remove(null);
return {};
}
}
// var result = await read(id, params);
try {
var result = await collection.findAndModify(
query: where.id(_makeId(id)), remove: true);
return _jsonify(result ?? {});
} catch (e, st) {
//printDebug(e, st, 'REMOVE');
throw AngelHttpException(stackTrace: st);
}
}