Knex.js logo
SQL query builder for Postgres, MySQL, MariaDB, SQLite3, and Oracle

What is Knex.js?

Knex.js is a "batteries included" SQL query builder for Postgres, MySQL, MariaDB, SQLite3, and Oracle designed to be flexible, portable, and fun to use. It features both traditional node style callbacks as well as a promise interface for cleaner async flow control, a stream interface, full featured query and schema builders, transaction support (with savepoints), connection pooling and standardized responses between different query clients and dialects.
Knex.js is a tool in the Database Tools category of a tech stack.
Knex.js is an open source tool with 9.8K GitHub stars and 1.2K GitHub forks. Here’s a link to Knex.js's open source repository on GitHub

Who uses Knex.js?

Companies
10 companies use Knex.js in their tech stacks, including Decision6, Zube, and Habx.

Developers
9 developers use Knex.js.

Knex.js Integrations

MySQL, PostgreSQL, SQLite, Oracle, and Trails are some of the popular tools that integrate with Knex.js. Here's a list of all 5 tools that integrate with Knex.js.

Why developers like Knex.js?

Here’s a list of reasons why companies and developers use Knex.js
Knex.js Reviews

Here are some stack decisions, common use cases and reviews by companies and developers who chose Knex.js in their tech stack.

Tim Nolet
Tim Nolet
Founder, Engineer & Dishwasher at Checkly · | 16 upvotes · 48K views
atChecklyHQ
vuex
Knex.js
PostgreSQL
Amazon S3
AWS Lambda
Vue.js
hapi
Node.js
GitHub
Docker
Heroku

Heroku Docker GitHub Node.js hapi Vue.js AWS Lambda Amazon S3 PostgreSQL Knex.js Checkly is a fairly young company and we're still working hard to find the correct mix of product features, price and audience.

We are focussed on tech B2B, but I always wanted to serve solo developers too. So I decided to make a $7 plan.

Why $7? Simply put, it seems to be a sweet spot for tech companies: Heroku, Docker, Github, Appoptics (Librato) all offer $7 plans. They must have done a ton of research into this, so why not piggy back that and try it out.

Enough biz talk, onto tech. The challenges were:

  • Slice of a portion of the functionality so a $7 plan is still profitable. We call this the "plan limits"
  • Update API and back end services to handle and enforce plan limits.
  • Update the UI to kindly state plan limits are in effect on some part of the UI.
  • Update the pricing page to reflect all changes.
  • Keep the actual processing backend, storage and API's as untouched as possible.

In essence, we went from strictly volume based pricing to value based pricing. Here come the technical steps & decisions we made to get there.

  1. We updated our PostgreSQL schema so plans now have an array of "features". These are string constants that represent feature toggles.
  2. The Vue.js frontend reads these from the vuex store on login.
  3. Based on these values, the UI has simple v-if statements to either just show the feature or show a friendly "please upgrade" button.
  4. The hapi API has a hook on each relevant API endpoint that checks whether a user's plan has the feature enabled, or not.

Side note: We offer 10 SMS messages per month on the developer plan. However, we were not actually counting how many people were sending. We had to update our alerting daemon (that runs on Heroku and triggers SMS messages via AWS SNS) to actually bump a counter.

What we build is basically feature-toggling based on plan features. It is very extensible for future additions. Our scheduling and storage backend that actually runs users' monitoring requests (AWS Lambda) and stores the results (S3 and Postgres) has no knowledge of all of this and remained unchanged.

Hope this helps anyone building out their SaaS and is in a similar situation.

See more
Tim Nolet
Tim Nolet
Founder, Engineer & Dishwasher at Checkly · | 10 upvotes · 4.6K views
atChecklyHQ
Knex.js
Node.js
Heroku Postgres
Heroku
PostgreSQL

PostgreSQL Heroku Heroku Postgres Node.js Knex.js

Last week we rolled out a simple patch that decimated the response time of a Postgres query crucial to Checkly. It quite literally went from an average of ~100ms with peaks to 1 second to a steady 1ms to 10ms.

However, that patch was just the last step of a longer journey:

  1. I looked at what API endpoints were using which queries and how their response time grew over time. Specifically the customer facing API endpoints that are directly responsible for rendering the first dashboard page of the product are crucial.

  2. I looked at the Heroku metrics such as those reported by heroku pg:outlier and cross references that with "slowest response time" statistics.

  3. I reproduced the production situation as best as possible on a local development machine and test my hypothesis that an composite index on a uuid field and a timestampz field would reduce response times.

This method secured the victory and we rolled out a new index last week. Response times plummeted. Read the full story in the blog post.

See more
Wei Wei
Wei Wei
Computer Science, Bachelor at Flux · | 1 upvotes · 1.5K views
atFlux Work
Knex.js

Not an ORM but a query builder. So developers are encouraged or sometimes forced to think about SQL and database layer, which is a good thing. Knex.js

See more

Knex.js's features

  • SQL query builder for Postgres, MySQL, MariaDB, SQLite3, and Oracle

Knex.js Alternatives & Comparisons

What are some alternatives to Knex.js?
Knex.js
Knex.js is a "batteries included" SQL query builder for Postgres, MySQL, MariaDB, SQLite3, and Oracle designed to be flexible, portable, and fun to use. It features both traditional node style callbacks as well as a promise interface for cleaner async flow control, a stream interface, full featured query and schema builders, transaction support (with savepoints), connection pooling and standardized responses between different query clients and dialects.
Sequel Pro
Sequel Pro is a fast, easy-to-use Mac database management application for working with MySQL databases.
PostGIS
PostGIS is a spatial database extender for PostgreSQL object-relational database. It adds support for geographic objects allowing location queries to be run in SQL.
Open PostgreSQL Monitoring
Open PostgreSQL Monitoring is a free software designed to help you manage your PostgreSQL servers.
Flyway
Easy to setup, simple to master. Flyway lets you regain control of your database migrations with pleasure and plain sql. Solves only one problem and solves it well. Flyway migrates your database, so you don't have to worry about it anymore.
See all alternatives

Knex.js's Stats