bashleigh / typeorm-polymorphic

Typeorm polymorphic relationship management
MIT License
198 stars 38 forks source link

Creates N queries for hydrateMany #9

Open xtrinch opened 3 years ago

xtrinch commented 3 years ago

This package creates one query per item for hydrateMany, and that is very slow as it would do 50 separate queries for 50 items that you want to hydrate.

It should make one query for all entities and then just map the result to the entities you want to hydrate.

jspizziri commented 3 years ago

I think it should either do that OR execute 1 query per entity type.

@bashleigh , any thoughts on this? I'd potentially be interested in working on a PR if you were on board.

bashleigh commented 3 years ago

@jspizziri Yes please do! That would've been a much better solution! Can't remember why I did each programatically! There's also an issue surrounding the calling to the database on the child->parent side that you might be able to resolve at the same time. The conditions I made seem to always favour the wrong relationship