I'm quite new to Supabase and PostgreSQL and have stumbled upon a question. If I'm creating a Todo app where people should be able to sign in and depending on subscription type (regular users or pro accounts) the total number of todos should be restricted. Let's say that regular users should be able to post 20 todos but pro users should be unlimited.
Here is the table I'm using:
account table
- id(uuid)
- subscriptionType(users/pro)
- toDoCount (number. Totalt number of todos)
todo table
- id
- userId
- title
- description
But how would I write policies that allow inserts only if 1. User is authenticated 2. toDoCount limit is not exceeded.
I'm creating the app with Ionic/angular.
Grateful for answers