@feathersjs/knex adapter provides SQL database integration through Knex.js, supporting PostgreSQL, MySQL, SQLite, MSSQL, Oracle, and other SQL databases with transactions, joins, and advanced querying.
Installation
Install dependencies
Install the Knex adapter, Knex.js, and your database driver:
- PostgreSQL
- MySQL
- SQLite
- MSSQL
Configuration
Service Options
The Knex adapter requires these options:Example Configuration
Querying
Basic Queries
The Knex adapter supports all standard Feathers query operators:SQL-Specific Operators
The Knex adapter includes SQL-specific operators:Raw Knex Queries
Pass custom Knex query builders:Data Manipulation
Create
Update
Patch
Remove
Transactions
The Knex adapter provides powerful transaction support:Using Transaction Hooks
Transaction Context
Transactions maintain context across hooks:Advanced Features
Table Schemas
Create and manage database schemas:Joins and Relations
Perform joins using custom Knex queries:Field Selection
Type Safety
Full TypeScript support with generics:Error Handling
The adapter converts SQL errors to Feathers errors:Connection Pooling
Configure connection pooling for better performance:Next Steps
MongoDB Adapter
Learn about the MongoDB adapter
Common Patterns
Explore adapter patterns
Hooks
Add hooks to your services
Validation
Validate your data with schemas