PG Query Context
Secure Session Context Management
A small utility for executing PostgreSQL queries within a session context. Set session-level variables for RLS and other scoped operations with automatic transaction management.
Set role, user ID, and custom variables
Automatic BEGIN/COMMIT with rollback on error
Perfect for Row-Level Security operations
Secure and reliable session context management
Set PostgreSQL session variables like role and user ID using set_config for secure, scoped operations.
Automatically wraps execution in transactions with BEGIN/COMMIT and automatic rollback on errors.
Perfect for implementing Row-Level Security policies with proper user context and role switching.
Works seamlessly with both pg.Pool and pg.Client instances for maximum flexibility.
Minimal overhead utility that focuses on doing one thing well - session context injection.
Clean, straightforward API that makes complex session management simple and reliable.
Execute PostgreSQL queries with session context variables set automatically. Perfect for implementing secure, role-based database operations.
Integrate with Express.js applications to handle authentication tokens and user context in a secure, transaction-safe manner.
Implement Row-Level Security policies by setting user roles and context variables that PostgreSQL RLS policies can use for access control.