Fork additions
@abedmurrar/objection is a fork of objection.js 3.1.5. This section only documents what the fork adds or changes. For everything else, the guide and the API reference of this site, which come from objection.js, still apply.
Installation
sh
npm install @abedmurrar/objection knexExisting code imports from 'objection'. To keep those imports working, install the fork under that name:
sh
npm install objection@npm:@abedmurrar/objectionReleases are published under npm's latest dist-tag. Prereleases, when there are any, go to next.
Requirements
| Dependency | Requirement |
|---|---|
| knex | 3.3 or newer |
| ajv | 8.20 or newer (comes as a dependency) |
| MySQL | 8.0.17 or newer (tested on 8.4 with the mysql2 driver). MySQL 5.7 and older aren't supported |
| MariaDB | 10.6 or newer (tested on 10.6 and 11.4 with the mariadb driver). See MariaDB |
| SQLite | 3.35 or newer for batch inserts, 3.25 or newer for window functions |
| Node.js | 24 or newer (24 and 26 are tested) |
What the fork adds
| Page | Summary |
|---|---|
| Breaking changes | Security and behaviour fixes that change what queries do: escaped JSON keys, orWhere grouping, for() checks, unsupported dialects, NULL JSON columns, knex 3.3, MySQL graph concurrency. |
| MySQL | MySQL and MariaDB. JSON field expressions, the whereJson* methods, whereJsonOverlaps(), MySQL casts, batch inserts (also on SQLite), and an fn.* helper for every MySQL 8.4 built-in function. |
| Expressions | eq(), gt(), and(), plus(), ... on ref(), val(), fn() and raw(). Also fn.case(), fn.exists(), fn.excluded(), filtered aggregates, window functions and none(). |
| Joins and model classes | Model classes in place of table names, Model.ref() in join callbacks, onJsonPathEquals(), and fixes for raw columns in whereIn() and subqueries in joins. |
| Performance | Less work per query than objection.js 3.1.5: shared validators for bound classes, a faster deep clone, cached schema checks, faster parsing of joined rows, hooks without promises and batched graph inserts on MySQL. With benchmarks, also against other ORMs on MySQL. |
| knex methods | The knex methods objection didn't have: andHaving*, comment(), hintComment(), using(), finally() and or in joins. How to upsert, and what is left out on purpose. |
| Ported from ditojs/objection | Fixes ported from Jürg Lehni's fork, which publishes the objection package, with links to the original commits. |
| TypeScript | Relations inferred from relationMappings, results that only contain loaded relations, checked relation expressions, modifiers and Model.ref() columns, typed fn/ref results, and a simpler custom query builder setup. |
The changelog lists each change per release. The migration guide has before and after examples for upgrading TypeScript code.