objection.js
objection.js copied to clipboard
query row based on some row exists in a related table
Consider the following 3 tables:
-
book_components
id title 1 chapter 1 2 chapter 2 -
file_versions
id book_component_id file_id 1 1 1 2 1 2 3 2 3 -
files
id title category 1 med.xml converted 2 req.xml source 3 doc.xml source
Now I want to fetch all the book components for which at least on file exists with category converted exists. So, for minimal example shown above, the query should return the row from book_components
where id = 1
. Because for that there exists a file converted file in the files table (id = 1
).
Is there a way to do this via Objection?