Vincit / objection.js

An SQL-friendly ORM for Node.js
https://vincit.github.io/objection.js
MIT License
7.24k stars 636 forks source link

It is possible to add the postgres ONLY keyword to a query? (Question) #2182

Open stoickeyboard opened 2 years ago

stoickeyboard commented 2 years ago

Is there a way to add the ONLY keyword to a postgres query? I'm able to do it without a Model and using knex with .from(knex.raw(ONLY parent)) directly but I was wondering if it were possible to modify a query to add ONLY. For example, I'm trying to perform a query involving inherited tables like so.

SELECT * FROM ONLY parent NATURAL FULL JOIN child;

with .joinRaw, I can add the NATURAL FULL JOIN.

I tried messing around with modifiers but couldn't seem to get it to work.

lehni commented 1 year ago

Knex supports this as an option on knex() also: https://knexjs.org/guide/query-builder.html#knex

Do you have a suggestion how this could be added to Objection models?