Objection.js

An SQL-friendly ORM for Node.js

Get Started →

Objection.js is an ORM (opens new window) for Node.js (opens new window) that aims to stay out of your way and make it as easy as possible to use the full power of SQL and the underlying database engine while still making the common stuff easy and enjoyable.

Even though ORM is the best commonly known acronym to describe objection, a more accurate description is to call it a relational query builder. You get all the benefits of an SQL query builder but also a powerful set of tools for working with relations.

Objection.js is built on an SQL query builder called knex (opens new window). All databases supported by knex are supported by objection.js. SQLite3, Postgres and MySQL are thoroughly tested (opens new window).

What objection.js gives you:

What objection.js doesn't give you:

  • A custom query DSL. SQL is used as a query language. This doesn't mean you have to write SQL strings though. A query builder based on knex (opens new window) is used to build the SQL. However, if the query builder fails you for some reason, raw SQL strings can be easily written using the raw helper function.
  • Automatic database schema creation and migration from model definitions. For simple things it is useful that the database schema is automatically generated from the model definitions, but usually just gets in your way when doing anything non-trivial. Objection.js leaves the schema related things to you. knex has a great migration tool (opens new window) that we recommend for this job. Check out the example project (opens new window).

The best way to get started is to clone our example project (opens new window) and start playing with it. There's also a typescript version (opens new window) available.

Check out this issue (opens new window) to see who is using objection and what they think about it.