RLS on related table

Hey, I've got two tables:
mods, with the columns id, user_id, mod_text
mod_tags, with the columns id, mod_id, type

mods has a one to many relationship to mod_tags, through mods.id to mod_tags.mod_id

In my JS code, I upsert any modifications to the row in mods, then I try to insert any new rows into mod_tags.

Updates to mods are all good, it's been running fine for ~1.5 years with a very basic RLS, checking the mods.user_id row vs the authenticated user.

But I've recently added mod_tags and I need to check the relation to the row in mods to get the user_id column. I've spent at least an hour with the LLM on the site and haven't got anywhere.

Can anyone point me in the right direction on how to get this working?
Was this page helpful?