docs: Simplify auth examples with OUT parameter

The jwt_token type was not created consistently in all examples, which can
be confusing when following those. To return an object with a single key
named token, it's enough to have an OUT parameter to the function.

Resolves https://github.com/PostgREST/postgrest-docs/issues/280
This commit is contained in:
Wolfgang Walther
2024-02-21 09:40:11 +01:00
committed by Wolfgang Walther
parent 7c6c056e92
commit 9b1ff2235a
3 changed files with 6 additions and 23 deletions
+1 -1
View File
@@ -166,7 +166,7 @@ Another option is to define the function with the :code:`SECURITY DEFINER` optio
-- login as a user wich has privileges on the private schemas
-- create a sample function
create or replace function login(email text, pass text) returns jwt_token as $$
create or replace function login(email text, pass text, out token text) as $$
begin
-- access to a private schema called 'auth'
select auth.user_role(email, pass) into _role;