pub async fn write_delete<R: Resource>(
cx: &Cx,
record: &R::Model,
ex: &mut dyn Executor,
) -> Result<(), WriteError>Expand description
The derived delete: stamps the soft_delete column with
the time on a resource that declares one, and removes the row on any other, through ex.
It writes through the tenant-scoped query, filtered to the record’s primary key, so a record
outside the request’s tenant is left alone. An overriding
delete_record that refuses some records delegates the others
here:
impl Resource for OrderResource {
async fn delete_record(
cx: &Cx,
order: &Order,
ex: &mut dyn toasty::Executor,
) -> Result<(), WriteError> {
if order.paid {
return Err(WriteError::declined("A paid order stays"));
}
write_delete::<Self>(cx, order, ex).await
}
}§Errors
WriteError::Failed for a resource the context’s panel does not mount, a soft-delete lens
naming no column (the mount refuses it first), or the driver’s error.