Checking for counts in RLS
Hey, I've got a table with 3 rows (which matter)
ID = PK
user_id=uuid
lesson=int
I want a user to only be allowed to create a new row if they don't have that specific lesson yet. (+ they can only create a row for their user_id)
This can't happen:
id: 1; user_id=1; lesson=1
id: 2; user_id=1; lesson=1
This can happen:
id: 1; user_id=1; lesson=1
id: 2; user_id=1; lesson=2
I've currently got this in the CHECK part:
Problem is, I can't seem to get the
How do I get that newRow.lecture in there?
Thanks
ID = PK
user_id=uuid
lesson=int
I want a user to only be allowed to create a new row if they don't have that specific lesson yet. (+ they can only create a row for their user_id)
This can't happen:
id: 1; user_id=1; lesson=1
id: 2; user_id=1; lesson=1
This can happen:
id: 1; user_id=1; lesson=1
id: 2; user_id=1; lesson=2
I've currently got this in the CHECK part:
Problem is, I can't seem to get the
("lectureSeat".lecture = 1) part right, when I try ("lectureSeat".lecture = lecture) it just replaces it with ("lectureSeat".lecture = "lectureSeat".lecture ) which is of course always true and doesn't work.How do I get that newRow.lecture in there?
Thanks