PostgreSQL Adapter

April 10, 2025

Deprecated Feature

@c15t/backend v1 did not deliver the flexibility we wanted and fell short of our standards. It is now deprecated as we work on a full rewrite, with v2 entering canary soon. This does not affect consent.io deployments, which remain stable.

Installation

Install the PostgreSQL adapter and its dependencies:

Configuration

Configure the PostgreSQL adapter with your connection details:

Schema Management

Initialize your database schema:

Usage Examples

Basic CRUD Operations

Transactions

Advanced Queries

Using PostgreSQL-Specific Features

Performance Optimization

Best Practices

  • Use connection pooling for efficient resource management
  • Implement database indexes for frequently queried columns
  • Use transactions for operations that must succeed or fail together
  • Consider using prepared statements for repetitive queries (handled automatically)
  • Leverage PostgreSQL-specific features like JSON/JSONB, array types, and full-text search
  • Regularly VACUUM and ANALYZE your database for performance maintenance
  • Set appropriate statement timeouts to prevent long-running queries

Monitoring and Management

Limitations

  • Requires a running PostgreSQL server
  • More complex setup compared to SQLite
  • Connection management adds complexity