riouha
riouha

Reputation: 1

create table from model in objection.js

i want to use an ORM for oracle in nodejs. in my searches i see many ORM but I narrow it down to typeorm and objection.

I take an example of objection from github but tables created from migration not from models.

How can I create table from a defined model?

Upvotes: 0

Views: 1563

Answers (1)

Mikael Lepistö
Mikael Lepistö

Reputation: 19728

Objection does not support any ways to create migrations from models. You need to write migration files to create schema and then write Models that matches DB schema as much as you need (or even various models to map the same parts of DB if suitable).

There might be some support for that some day (as an external npm package), but biggest motivation to not have it in core is that it would be pretty limiting to use only ORM supported features of DB schema.

IMO DB schema should be designed first to be efficient in a way that it can be queried efficiently and ORM layer to access it should be done after that (of course it always some compromise between two extremes). I've seen many many badly designed schemas just because people have first write ORM representation of the data and then created some schema out of it without thinking too much DB level of things.

TypeORM that is more traditional ORM has something like that https://typeorm.io/#/migrations/generating-migrations

Upvotes: 2

Related Questions