TryGhost / NQL

MIT License
4 stars 8 forks source link

Added support for joining to virtual tables #24

Open daniellockyer opened 2 years ago

daniellockyer commented 2 years ago

⚠️ blocked to be merged until MySQL 5 has been dropped in Ghost

refs https://github.com/TryGhost/Team/issues/944

Currently mongo-knex does not allow setting up relations which use an aggregate function, e.g. filtering based on the SUM of a related column.

I initially looked at adding a new relation type like oneToOneAggregate but this proved to require large changes to the codebase, with a big increase in complexity.

The approach here is to allow consumers of the library to have the ability to define a virtual table as a knex query, which allows for more complex relations, including aggregates, or joins over multiple tables.