github.com/knex/knex

A query builder for PostgreSQL, MySQL, CockroachDB, SQL Server, SQLite3 and Oracle, designed to be flexible, portable, and fun to use.

Open this visualization on its own page →

Contributors

409

Lines of Code

9,573

From

2012-12-29

To

2020-12-22

About knex/knex

Knex is a SQL query builder for Node.js that supports multiple database systems including PostgreSQL, MySQL, MariaDB, CockroachDB, SQL Server, SQLite3, and Oracle. Rather than writing raw SQL strings, developers use Knex's JavaScript API to construct queries programmatically, which then generates the appropriate SQL dialect for their chosen database. The library is designed to be flexible and portable across different database backends.

The project includes a comprehensive feature set for working with databases, such as transaction support, connection pooling, streaming queries, and both promise-based and callback-based APIs. Knex comes with a thorough test suite and requires Node.js 16 or later. The library also supports TypeScript and can be used as an ES module, making it compatible with modern JavaScript development practices.

Knex serves as a foundation for higher-level database tools in the Node.js ecosystem. Several Object Relational Mappers like Objection.js and Mikro-ORM are built on top of Knex, allowing developers to choose between using Knex directly for query building or adopting a more full-featured ORM solution. The project maintains extensive documentation, a recipes wiki for common patterns, and an active community for support and discussions.

Share this video