Video by Joel Loh | AI Automations · streamed from YouTube. All rights remain with the creator.
Lesson 19: Like Counts with Supabase Triggers
About this lesson
In this part of the series, Joel Loh continues the like post functionality of the photo-sharing app by introducing Supabase triggers, using them to keep an accurate count of the likes on each post. It begins by answering the question of what triggers are: functions that the database runs automatically when something happens to a table, such as a new row being added or an existing row being removed. Because they run inside the database itself, triggers keep related data consistent without the app having to remember to do the work. The video then creates Supabase triggers that respond to likes being added and removed, so that the number of likes stored with each post goes up or down at the right moments. As with most database work, things do not always go smoothly the first time, and the video spends time debugging the triggers, showing how to track down and fix the problems that appear, which is valuable experience for anyone building with Supabase. With the count being maintained correctly, the next step is reflecting the like count in the app, displaying the number of likes alongside each post in FlutterFlow so that users can see how popular a post is. A test confirms that liking and unliking posts updates the count as expected. By the end of the video, every post shows an up-to-date like count managed by the database, and the next part starts building the user interface of the comment section. Afterwards, read Chapter 19 of the course book, which works out why a stored count is cheaper than counting by hand.