diff --git a/src/api/supabase/queries/plant_by_id.ts b/src/api/supabase/queries/plant_by_id.ts new file mode 100644 index 0000000..fe74918 --- /dev/null +++ b/src/api/supabase/queries/plant_by_id.ts @@ -0,0 +1,19 @@ +import { UUID } from 'crypto'; +import { Plant } from '@/types/schema'; +import supabase from '../createClient'; + +export async function get_plant_by_id( + i_state: string, + p_id: UUID, +): Promise { + const { data, error } = await supabase.rpc('get_plant_by_id', { + input_state: i_state, + plant_id: p_id, + }); + + if (error) { + throw new Error(`Error getting matching plant: ${error.message}`); + } + + return data; +}