I'm trying to write an action that takes an employee number as a parameter and returns the corresponding employee as a SupabasRow.
How can I check whether an employee has been found? (await supabase ...)
If no employee was found, my custom action should return "zero".
At the moment I'm getting an exception in console, if no employee was found.
Here my code:
Future<EmployeeRow?> getEmployeeByEmployeeNumber (String employeeNumber) async {
final supabase = SupaFlow.client;
final response = await supabase
.from('employee')
.select('*')
.eq('inventar_nr', employeeNumber)
.single();
//HOW TO CHECK IF A RECORD WAS FOUND?
if (response == null) {
print("response error!!!");
return null;
}
print(response);
return EmployeeRow(response);
}
Apart from https://supabase.com/docs/reference/dart/select, are there any examples
of how to proceed with SupaFlow.client ?
(Exception handling etc.)