I'm trying to insert into another table if a user has a certain role. The roles are currently stored on the user object as a json array [{'type': 'ADMIN'}]
My code is as follows
BEGIN
IF NEW.roles->'type' @> '"ADMIN"' THEN
// INSERT INTO new_table
END IF;
RETURN NEW;
END;
The row never gets inserted if the role is there. Is there a way to do IF statements on jsonb?