MCPcopy
hub / github.com/Vincit/objection.js

github.com/Vincit/objection.js @3.1.5-mod.1 sqlite

repository ↗ · DeepWiki ↗ · release 3.1.5-mod.1 ↗
3,201 symbols 8,774 edges 324 files 99 documented · 3%
README

Stand With Ukraine

Tests Join the chat at https://gitter.im/Vincit/objection.js

Objection.js

Objection.js is an ORM for Node.js 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. All databases supported by knex are supported by objection.js. SQLite3, Postgres and MySQL are thoroughly tested.

What objection.js gives you:

What objection.js doesn't give you:

  • A fully object oriented view of your database With objection you don't work with entities. You work with queries. Objection doesn't try to wrap every concept with an object oriented equivalent. The best attempt to do that (IMO) is Hibernate, which is excellent, but it has 800k lines of code and a lot more concepts to learn than SQL itself. The point is, writing a good traditional ORM is borderline impossible. Objection attempts to provide a completely different way of working with SQL.
  • 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 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 that we recommend for this job. Check out the example project.

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

Check out this issue to see who is using objection and what they think about it.

Shortcuts:

Extension points exported contracts — how you extend this code

Aliasable (Interface)
(no doc) [4 implementers]
typings/objection/index.d.ts
ReferenceBuilder (Interface)
(no doc) [3 implementers]
typings/objection/index.d.ts
AjvConfig (Interface)
(no doc) [2 implementers]
typings/objection/index.d.ts
ColumnNameMappers (Interface)
(no doc) [2 implementers]
typings/objection/index.d.ts
CatchablePromiseLike (Interface)
(no doc) [1 implementers]
typings/objection/index.d.ts

Core symbols most depended-on inside this repo

then
called by 2291
lib/queryBuilder/QueryBuilder.js
query
called by 1794
typings/objection/index.d.ts
where
called by 621
lib/queryBuilder/QueryBuilderBase.js
knex
called by 526
typings/objection/index.d.ts
select
called by 404
lib/queryBuilder/QueryBuilderBase.js
orderBy
called by 387
lib/queryBuilder/QueryBuilderBase.js
fromJson
called by 386
typings/objection/index.d.ts
$relatedQuery
called by 342
lib/model/Model.js

Shape

Method 1,582
Function 841
Class 640
Interface 138

Languages

TypeScript100%

Modules by API surface

typings/objection/index.d.ts202 symbols
lib/queryBuilder/QueryBuilderBase.js173 symbols
lib/queryBuilder/QueryBuilder.js149 symbols
lib/model/Model.js117 symbols
lib/utils/clone.js86 symbols
tests/ts/examples.ts62 symbols
tests/unit/queryBuilder/QueryBuilder.js59 symbols
lib/queryBuilder/QueryBuilderOperationSupport.js57 symbols
lib/queryBuilder/parsers/relationExpressionParser.js50 symbols
lib/queryBuilder/parsers/jsonFieldExpressionParser.js41 symbols
lib/queryBuilder/RelationExpression.js39 symbols
testUtils/TestSession.js38 symbols

Dependencies from manifests, versioned

@types/koa2.11.0 · 1×
@types/koa-bodyparser4.3.0 · 1×
@types/koa-router7.0.42 · 1×
@types/node22.7.0 · 1×
ajv8.17.1 · 1×
ajv-formats2.1.1 · 1×
axios0.19.0 · 1×
chai4.3.10 · 1×
chai-subset1.6.0 · 1×
db-errors0.2.3 · 1×
eslint8.54.0 · 1×
eslint-formatter-codeframe7.32.1 · 1×

For agents

$ claude mcp add objection.js \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact