|
|
|
|
|
by brendanyounger
885 days ago
|
|
Almost. What I wrote is more like: create view LoggedInUserView as
select u.id as id, u.name as name, u.email as email
from Users u
join Cookies c on c.name = 'login' and u.id = c.payload->>'userId';
where payload is a json blob. (Indent code by 2+ spaces.)Most people wouldn't design their schema in a SQL database like this with a bunch of special-use relations/views, but datalog encourages you to do so since defining a new relation is the only means of abstraction. In effect, you've created an API endpoint similar to /api/auth/users and, what's more, you can use the LoggedInUserView in other rules to define new relations. |
|