Skip to content

@abedmurrar/objectionThe SQL ORM for Node.js that knows what your queries return

Built on knex. Strictly typed, fast, and at home on Postgres, MySQL, MariaDB and SQLite. A fork of objection.js.

@abedmurrar/objection is an ORM for Node.js, or more precisely a relational query builder: you get everything an SQL query builder gives you, plus models, relations, eager loading, graph inserts and upserts, transactions and validation. It's built on knex, so every database knex supports works. Postgres, MySQL, MariaDB and SQLite are tested in CI.

It started as a fork of objection.js 3.1.5 by Sami Koskimäki and its contributors, and keeps its API. The guide and the API reference of this site come from objection.js and apply as they are; the fork section covers what this package adds and changes.

sh
npm install @abedmurrar/objection knex

Coming from objection.js? Install it as objection@npm:@abedmurrar/objection and existing imports keep working. Then read the breaking changes and the migration guide.

What you get:

What you don't get:

  • A query language of its own. SQL is the query language. You don't have to write SQL strings: the query builder is knex, and the raw helper is there for anything it can't express.
  • A database schema generated from the models. That gets in the way as soon as things aren't trivial, so the schema is left to you. knex has a great migration tool for this job.

The best way to get started is the example project. There's also a TypeScript version.

MIT Licensed. Built on objection.js by Sami Koskimäki and its contributors.