Types that know what you loaded
Relations are inferred from relationMappings, results only contain the relations a query fetched, and relation expressions, modifiers and Model.ref() columns are checked at compile time.
Built on knex. Strictly typed, fast, and at home on Postgres, MySQL, MariaDB and SQLite. A fork of objection.js.
Relations are inferred from relationMappings, results only contain the relations a query fetched, and relation expressions, modifiers and Model.ref() columns are checked at compile time.
13% to 19% less of objection's own work per query than objection.js 3.1.5, toJSON() 44% less, validation 55% less, a validated insert in a new transaction 91% less. Same SQL, same results.
JSON field expressions, the whereJson* methods, batch inserts and an fn.* helper for every MySQL 8.4 function. MariaDB 10.6 and 11.4 are tested in CI.
Pet.ref('age').gte(3), fn.count().filter(...), fn.case(), window functions and more, all typed.
Escaped JSON field keys (an SQL injection in objection.js 3.1.5), orWhere() that can't match other owners' rows, and a for() that is no longer ignored.
Written in strict TypeScript. Node.js 24+, ES modules and CommonJS from one package, knex 3.3, no lodash and no bluebird.
@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.
npm install @abedmurrar/objection knexComing 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:
The best way to get started is the example project. There's also a TypeScript version.