Summary
Keywords
Full Transcript
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: https://youtu.be/ZL83TpSECys Part 2: https://youtu.be/GhDgFXY-vFA Part 3: https://youtu.be/Wc7hP9y3B-M Part 4: https://youtu.be/zmcRj46V8Bs Part 5: https://youtu.be/qtE-NQ3sGvs Part 6: https://youtu.be/bszv7Im2c-g Part 7: https://youtu.be/gdeIXkMKOjA Part 8: https://youtu.be/ziyMqZ6M2c8 Part 9: https://youtu.be/BF576xwOPNI Part 10: https://youtu.be/Rqb45V2aKJE Part 11: https://youtu.be/SbJtTuH2LFY 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/flutterflow 🎉 Your love is much appreciated ... A like to this video is like a High Five!!! Thank you all.
