-
-
Notifications
You must be signed in to change notification settings - Fork 611
Description
Is your feature request related to a problem? Please describe.
I use this decorator in many different places for many different classes, and find it a bit extreme to attach orm to every single one. Instead, I'd love it if you could optionally pass in orm as an argument to @UseRequestContext() (which is already a decorator factory, so not a breaking change). This way, someone can use it without having to add any properties to the class.
Personally, I'd create my own decorator that just looks like this:
export const UseRequestContext = OriginalUseRequestContext.bind(orm);This way the decorator can always access the context it needs and I wouldn't need to do anything extra.
Describe the solution you'd like
I'd like UseRequestContext's parameters to be typed as (orm?: MikroORM) and the decorator to use orm ?? this.orm instead of just this.orm for all related operations. I didn't submit my own PR because I'm clueless with tests, sorry 😭
Describe alternatives you've considered
Adding the orm property to every class. It works, but is kind of inconvenient :(