SQL Query Builder
Knex.js provides a flexible and powerful SQL query builder that allows developers to create complex queries using a fluent, chainable API. This can make writing and maintaining SQL queries simpler and more intuitive.
Database Agnostic
Knex.js supports multiple database systems such as PostgreSQL, MySQL, SQLite3, Oracle, and others. This makes it easier to switch between different databases without changing the application code.
Promise-based API
Its promise-based API allows for better handling of asynchronous operations and more readable code, making it easier to work with Node.js’s asynchronous nature.
Migration Tooling
Knex.js comes with built-in migration support, enabling developers to version and manage database schema changes in a structured manner.
Active Development & Community
Knex.js has a strong community and is actively maintained, ensuring regular updates, bug fixes, and continuous improvement.
Here's the thing that always bugged me - writing database code over and over for different DBs. Like, why can't everything be as smooth as Laravel's Eloquent? That's where Knex comes in - write once, run anywhere (with a bit of config magic)! - Source: dev.to / 3 months ago
If you want to make database queries in Ghost to fetch, for example, the current post, it’s possible and not difficult. You can use a library like knex (https://knexjs.org/), which is a clear and fast SQL query builder. Remember that you’ll need handlebars-async-helpers for this. Configure knex properly to connect to Ghost’s database. - Source: dev.to / 4 months ago
In this post, I’ll walk you through how to work with ORMs like Prisma, Drizzle and Knex.js when working with Encore.ts. - Source: dev.to / 5 months ago
Knex: SQL query builder used in the application to manage sql databases queries in a easier way by letting knex handel all the hassle for us. - Source: dev.to / 10 months ago
Knex.js is a versatile SQL query builder primarily used with Node.js. It is designed for flexibility, portability, and ease of use across various databases, such as PostgreSQL, CockroachDB, MSSQL, MySQL, MariaDB, SQLite3, Better-SQLite3, Oracle, and Amazon Redshift. - Source: dev.to / 10 months ago
Since most of these APIs will be simple "CRUD" (Create/Read/Update/Delete) endpoints, let's build this service using Knex.js, an ORM Library that makes building CRUD endpoints really simple. - Source: dev.to / 11 months ago
Looks exactly like https://knexjs.org/ but I bet there are query builders / ORMs with same syntax. - Source: Hacker News / 11 months ago
AdonisJS core team has created/maintains Lucid. It is a SQL query builder, and an Active Record ORM built on top of Knex. - Source: dev.to / about 1 year ago
Now, why not use an ORM? I've seen performance issues too many times with ORMs. I prefer writing my own SQL to avoid surprises. After all, I know the database schema and writing code for a specific purpose very often leads to better performance than generic code. ORMs have to support all kinds of database schemas. I only have to support mine. Having successfully used Knex.js in NodeJS (a popular query builder) in... - Source: dev.to / over 1 year ago
Given the dynamic nature of the schema, we employ Knex, a query builder, for database access. - Source: dev.to / over 1 year ago
SQL is an old, irregular language to work with, but it is better known than HCL and SQL already has it's own Pulumi/CDK in the form of every ORM with introspection (like Javascript's Prisma, Python's Django, Go's XO etc) and QueryBuilder (LINQ, Knex, etc) in whatever programming language you prefer. You probably already know it. - Source: dev.to / about 2 years ago
How does HN receive SQL builders in general? I feel like most of us agree ORMs are typically a bad idea. I feel like that almost instantly leaves the need for "something" to take its place. In my experience, it's typically been a query builder like this. I've also tried: https://knexjs.org/ https://www.npmjs.com/package/sql-template-strings ("out of date" since like 2016?... - Source: Hacker News / over 2 years ago
Of course, this is a trivial example that you probably won’t find in production code, but there are many projects that use lazy-evaluated Promise-like objects. Probably the most common example is with database ORMs and query builders like Knex.js or Prisma. - Source: dev.to / over 2 years ago
Why not just use a mariadb or postgres docker image? heck, even sqlite should be fine, given the simplicity of your needs. I work with nodejs myself, I'd highly recommend knexjs for this- it's super flexible! Source: over 2 years ago
Also, but that's just me, I would at least use a query builder like Knex to avoid having to write sql in code (if not using an ORM but that might be an overkill depending on what you've got to do). Source: over 2 years ago
It’s based on the Knex.js (https://knexjs.org/) query builder for JavaScript. I’m personally using it with MySQL and PostgreSQL databases with fantastic results. If you’re interested and need help feel free to PM me and I’ll try to help out as much as I can. Source: over 2 years ago
MikroOrm is a pretty fantastic project IMO. It uses Knex as the query builder so maybe you can just use that directly: https://knexjs.org/. - Source: Hacker News / over 2 years ago
Our backend server had been using AdminJS with Typeorm. But recently, we migrate our server from Typeorm to Knex. It tooks about a week, but after migration, we noticed that there is no adapter that doesn't need an ORM. So I made adminjs-sql project. If you are interested in, checkout adminjs-sql. Contributions are welcome!! Source: over 2 years ago
I am bit new to SQL and using knex.jsI am trying to fetch data by combining two tables, which must be a trivial thing I reckon. Source: over 2 years ago
That, or a query builder like Knex: https://knexjs.org/. Source: over 2 years ago
By building a demo project, we’ve learned how to build REST endpoints with Knex and PostgreSQL. We started by introducing PostgreSQL and Knex and why you should use them, then we created a blog project for the demonstration. Now that you’ve gotten the knowledge you seek, how would you use a query builder in your next project? Consider learning more about Knex from their official website and take things even further! - Source: dev.to / over 2 years ago
Do you know an article comparing Knex.js to other products?
Suggest a link to a post with product alternatives.
This is an informative page about Knex.js. You can review and discuss the product here. The primary details have not been verified within the last quarter, and they might be outdated. If you think we are missing something, please use the means on this page to comment or suggest changes. All reviews and comments are highly encouranged and appreciated as they help everyone in the community to make an informed choice. Please always be kind and objective when evaluating a product and sharing your opinion.