- Notifications
You must be signed in to change notification settings - Fork642
An SQL-friendly ORM for Node.js
License
Vincit/objection.js
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Objection.js is anORM forNode.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 ita 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 calledknex. All databases supported by knex are supported by objection.js.SQLite3,Postgres andMySQL arethoroughly tested.
What objection.js gives you:
- An easy declarative way ofdefining models and relationships between them
- Simple and fun way tofetch, insert, update and delete objects using the full power of SQL
- Powerful mechanisms foreager loading,inserting andupserting object graphs
- Easy to usetransactions
- OfficialTypeScript support
- OptionalJSON schema validation
- A way tostore complex documents as single rows
What objection.jsdoesn't give you:
- A fully object oriented view of your databaseWith objection you don't work with entities. You work with queries. Objection doesn't try to wrap every concept with anobject oriented equivalent. The best attempt to do that (IMO) is Hibernate, which is excellent, but it has 800k linesof code and a lot more concepts to learn than SQL itself. The point is, writing a good traditional ORM is borderlineimpossible. 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 onknex isused to build the SQL. However, if the query builder fails you for some reason, raw SQL strings can be easilywritten using theraw 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 thingsto you. knex has a greatmigration tool that we recommend for this job. Checkout theexample project.
The best way to get started is to clone ourexample project and start playing with it. There's also atypescript version available.
Check outthis issue to see who is using objection and what they think about it.
Shortcuts:
About
An SQL-friendly ORM for Node.js
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.