Start with the problem
Listing your plants should never return someone else’s. I used to add WHERE user_id = $1 to each query. With
row-level security, Postgres can apply the ownership rule even when the query doesn’t repeat it.
Projects / active
A gardening app I’m building in Go. It’s also where I tried letting Postgres enforce who can see or change a plant, instead of repeating the same ownership check in every query.
Listing your plants should never return someone else’s. I used to add WHERE user_id = $1 to each query. With
row-level security, Postgres can apply the ownership rule even when the query doesn’t repeat it.
The old query, what changed, and how I pass the user’s identity into a database transaction.
The GopherCon UK talk uses LettuceGo and Banter Bus to show how Go handlers return fragments of HTML.