Kysely Adapter
The Kysely adapter provides type-safe SQL query building with support for multiple databases including PostgreSQL, MySQL, and SQLite.
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
First, install the Kysely package and the appropriate database driver:
Configuration
Configure the Kysely adapter with your database connection:
MySQL Configuration
SQLite Configuration
Usage Examples
Basic CRUD Operations
Transactions
Schema Management
Best Practices
- Use prepared statements - Kysely automatically uses prepared statements to prevent SQL injection
- Configure connection pooling - Set appropriate pool sizes based on your application needs
- Implement retry logic - Add retries for transient database errors
- Monitor query performance - Use the debug option to log slow queries during development
Limitations
- Schema must be created separately or with raw SQL
- Complex joins require custom SQL or advanced Kysely usage
Related Resources
Edit on GitHub
Last updated: April 10, 2025