nestjsx / crud

NestJs CRUD for RESTful APIs
https://github.com/nestjsx/crud/wiki
MIT License
4.09k stars 541 forks source link

[Feature Request] Join with on/filter conditions #396

Open jbjhjm opened 4 years ago

jbjhjm commented 4 years ago

Couldn't find this anywhere so I'll post it here as a feature request.

Missing a somewhat useful feature: Support for JOIN ON [...] conditions.

My personal use case looks like this for example: All of my database items feature a state column. Client API must only return enabled items. Of course this is the case for related items, too.

Did I miss something and it is already possible? Otherwise, are there plans to add this feature in near future?

Thanks for your work!

jbjhjm commented 4 years ago

Any news on this?

michaelyali commented 4 years ago

Hi, @jbjhjm Sorry for the late response. Yep, I had this feature request already and will try to ship it. Let me ask you - so, generally, this is needed for joining tables that don't have relations set up in entities, right?

jbjhjm commented 4 years ago

Sounds great @zMotivat0r !

Actually the request refers to existing relations, for example a endpoint returning a User with all related Blog posts which are PUBLISHED. So UserEntity has a One2Many or Many2Many relation to PostEntity defined, and one would need to do something like "JOIN ON [...relation...] AND post.published = 1",

Of course, if the implementation of relation-based and raw-join-based filters are similar, I'm sure there are users who'd be happy to use both.

michaelyali commented 4 years ago

and handle all this from the backend side only, right?

jbjhjm commented 4 years ago

in my use cases, yes. Allowing join conditions to be passed by parameters would be complex and I don't think there's need for url-specified filtering of related items. So, backend only.