If I make a request to delete, and the supplied id is not found in the db, how can I know that this operation did not complete successfully? The same goes for update and insert. I'm thinking of an optimal way, since for example, to find out if it was deleted correctly, I could make a query looking for that value, but it doesn't seem like the best way to me.
I tried to force the update by passing an id that doesn't exist, and, using the onError method, didn't catch any errors, even though it was displayed on the console.
.onError((error, stac) {
return const Center(
child: Text('Error'),
);
You can find out whether a delete operation succeded or not by wrapping your call with try/catch like this:
try {
await supabase.from('table').delete().eq('id', '1');
} catch(error) {
// error occured
print(error);
}
However, as @Randal Schwartz have stated, trying to delete or update a row that does not exist does not throw an error in SQL or in Supabase. If you really need to know if the data exists in the first place, you would have to do a select
operation to get the data.