Get Advice Icon

Need advice about which tool to choose?Ask the StackShare community!

Knex.js
Knex.js

76
88
+ 1
20
Mongoose
Mongoose

791
600
+ 1
38
Add tool

Knex.js vs Mongoose: What are the differences?

Developers describe Knex.js as "SQL query builder for Postgres, MySQL, MariaDB, SQLite3, and Oracle". 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. On the other hand, Mongoose is detailed as "MongoDB object modeling designed to work in an asynchronous environment". Let's face it, writing MongoDB validation, casting and business logic boilerplate is a drag. That's why we wrote Mongoose. Mongoose provides a straight-forward, schema-based solution to modeling your application data and includes built-in type casting, validation, query building, business logic hooks and more, out of the box.

Knex.js belongs to "Database Tools" category of the tech stack, while Mongoose can be primarily classified under "Object Document Mapper (ODM)".

"Write once and then connect to almost any sql engine" is the primary reason why developers consider Knex.js over the competitors, whereas "Well documented" was stated as the key factor in picking Mongoose.

Knex.js and Mongoose are both open source tools. It seems that Mongoose with 18.8K GitHub stars and 2.62K forks on GitHub has more adoption than Knex.js with 9.79K GitHub stars and 1.22K GitHub forks.

According to the StackShare community, Mongoose has a broader approval, being mentioned in 85 company stacks & 89 developers stacks; compared to Knex.js, which is listed in 10 company stacks and 9 developer stacks.

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.

What is Mongoose?

Let's face it, writing MongoDB validation, casting and business logic boilerplate is a drag. That's why we wrote Mongoose. Mongoose provides a straight-forward, schema-based solution to modeling your application data and includes built-in type casting, validation, query building, business logic hooks and more, out of the box.
Get Advice Icon

Need advice about which tool to choose?Ask the StackShare community!

Why do developers choose Knex.js?
Why do developers choose Mongoose?

Sign up to add, upvote and see more prosMake informed product decisions

    Be the first to leave a con
    What companies use Knex.js?
    What companies use Mongoose?

    Sign up to get full access to all the companiesMake informed product decisions

    What tools integrate with Knex.js?
    What tools integrate with Mongoose?

    Sign up to get full access to all the tool integrationsMake informed product decisions

    What are some alternatives to Knex.js and Mongoose?
    Slick
    It is a modern database query and access library for Scala. It allows you to work with stored data almost as if you were using Scala collections while at the same time giving you full control over when a database access happens and which data is transferred.
    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
    It lets you regain control of your database migrations with pleasure and plain sql. Solves only one problem and solves it well. It migrates your database, so you don't have to worry about it anymore.
    See all alternatives
    Decisions about Knex.js and Mongoose
    No stack decisions found
    Interest over time
    Reviews of Knex.js and Mongoose
    Review ofMongooseMongoose

    I inherited a stack where Mongoose is used in the database layer.

    It's been several months and it's still the single highest source of daily WT*s in my backend development. The API is full of irregularities and the design is a poor mix of object-orientation and stateful objects with a lot implicit behavior. Mongoose made the choices of taking the worst parts of ORMs and using them in a context where the benefits of ORMs don't apply. The only reason I'm keeping it is its handy .populate() feature. Expect bad surprises!

    How developers use Knex.js and Mongoose
    Avatar of Flux Work
    Flux Work uses Knex.jsKnex.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.

    Avatar of AyeDeals
    AyeDeals uses MongooseMongoose

    We use mongoose and node-native for database querying.

    Avatar of anthillsolutions
    anthillsolutions uses MongooseMongoose

    No-brainer for accessing Objects with NodeJS.

    Avatar of Zube
    Zube uses Knex.jsKnex.js

    Converts JS to SQL. Pretty awesome!

    How much does Knex.js cost?
    How much does Mongoose cost?
    Pricing unavailable
    Pricing unavailable
    News about Knex.js
    More news