delete method
Delete specific resource
Implementation
Future<int> delete(
String? password,
Resource? resource,
R5ResourceType? resourceType,
Id? id,
String? field,
String? value,
) async {
if ((resource != null && resource.resourceType != null) ||
(resourceType != null && id != null) ||
(resourceType != null && field != null && value != null)) {
Finder finder;
if (resource != null) {
finder = Finder(filter: Filter.equals('id', '${resource.id}'));
} else if (resourceType != null && id != null) {
finder = Finder(filter: Filter.equals('id', '$id'));
} else {
finder = Finder(filter: Filter.equals(field!, value));
}
_setStoreType(ResourceUtils
.resourceTypeToStringMap[resource?.resourceType ?? resourceType]!);
return await _resourceStore.delete(await _db(password), finder: finder);
} else {
throw const FormatException('Must have either: '
'\n1) a resource with a resourceType'
'\n2) a resourceType and an Id'
'\n3) a resourceType, a specific field, and the value of interest');
}
}