Sometimes it's important to offload certain activities to the backend even if it requires a little #lowcode. In this episode we do exactly that and perform total tasks and completed tasks count using the power of #Supabase triggers. This prevents us performing complex actions within #FlutterFlow. Hope you enjoy this episode.
Code Examples:
update_goal_task_count: (code)
BEGIN
IF (TG_OP = 'INSERT') THEN
UPDATE goals
SET no_tasks = no_tasks + 1
WHERE id = NEW.goal_id;
RETURN NEW;
ELSIF (TG_OP = 'DELETE') THEN
UPDATE goals
SET no_tasks = no_tasks - 1
WHERE id = OLD.goal_id;
IF (OLD.complete) THEN
UPDATE goals
SET no_tasks_complete = no_tasks_complete - 1
WHERE id = OLD.goal_id;
END IF;
RETURN OLD;
END IF;
RETURN NEW;
END
update_goal_tasks_completed_count: (code)
BEGIN
IF (TG_OP = 'UPDATE') AND (NEW.complete != OLD.complete) THEN
IF (NEW.complete = true) THEN
UPDATE goals
SET no_tasks_complete = no_tasks_complete + 1
WHERE id = NEW.goal_id;
ELSIF (NEW.complete = false) THEN
UPDATE goals
SET no_tasks_complete = no_tasks_complete - 1
WHERE id = NEW.goal_id;
END IF;
RETURN NEW;
END IF;
RETURN NEW;
END
If you missed an episode:
Part 1: • #FlutterFlow + #Supabase - Building a Goal...
Part 2: • #FlutterFlow + #Supabase - Building a Goal...
Part 3: • #FlutterFlow + #Supabase - Building a Goal...
Part 4: • #FlutterFlow + #Supabase - Building a Goal...
Part 5: • #FlutterFlow + #Supabase - Building a Goal...
Part 6: • #FlutterFlow + #Supabase - Building a Goal...
Part 7: • #FlutterFlow + #Supabase - Building a Goal...
Part 8: • #FlutterFlow + #Supabase - Building a Goal...
Part 9: • #FlutterFlow + #Supabase - Building a Goal...
Part 10: • #FlutterFlow + #Supabase - Building a Goal...
Part 11: • #FlutterFlow + #Supabase - Building a Goal...
If you love my content why not consider buying me a coffee, it's really appreciated:
https://bmc.link/thedigitalpro
00:00 Introduction
00:43 Quick Intro to Triggers in Supabase
01:29 Application changes intro
02:38 Supabase recap
03:29 Prequel to creating the function
06:07 Building the tasks count function
10:21 Creating the trigger to call the function
13:41 Testing the trigger
14:29 Adding deletes to the function
16:23 Testing the delete trigger
16:44 Adding the completed function
22:18 Testing the second trigger
23:48 Outro
_____
🚀 The Digital Pro's NoCode Academy on Patreon: https://www.thedigitalpro.co.uk/patreon
(official launch in September, but welcome to join today 😉)
🔥 If you love my content why not consider buying me a coffee, it's really appreciated: https://www.thedigitalpro.co.uk/coffee
👍 Support the channel and grab yourself a free FlutterFlow account by clicking here: https://www.thedigitalpro.co.uk/flutt...
🎉 Your love is much appreciated ... A like to this video is like a High Five!!! Thank you all.