vendredi 5 mai 2023

Index specific TypeORM entity fields

I'm building an indexing service to index various entity fields. I'd like to be able to add a decorator like @Searchable or similar to the fields I want to decorate and then using some kind of indexing service (and probably reflection) find all the entity classes (those with the @Entity decorator), then in each one of those, gather up all of the fields with @Searchable decorators applied to them.

The issue is - I'm running into issues trying to use reflection to find the entities an it's starting to feel like I'm approaching the issue wrong.

I've tried putting the smarts in the decorator and having it register with some kind of external service every time it's called, but this feels very fragile and requires a singleton of that service to be available to "hold" the data.





Aucun commentaire:

Enregistrer un commentaire