Hi Team,
I am developing a component which takes binding keys for repositories from the configuration, and I am fetching those repositories by code like below,
const repository = await this.application.get<TRepo>(
`repositories.${config.modelRepository}`
);
this instantiates the repository and gets back the expected result. After this, I am manually setting some properties on the repository class so that it could be used ahead in the future.
But when I hit an controller endpoint for the first time which injects this repository ,
export class UserController extends AuthenticationControllerMixin<
User,
Constructor<Object>
>(Object, options) {
constructor(
@inject('repositories.UserRepository')
public userRepository: UserRepository,
@service(ImagekitProvider) public imagekit: Imagekit
) {
super();
}
it creates a new instance of the Repository again, but further API hits don't.
What would be the reason the new Repository instance is getting generated 2 times
- with the application.get.
- when hitting a Controller endpoint for the first time.
Hi Team,
I am developing a component which takes binding keys for repositories from the configuration, and I am fetching those repositories by code like below,
this instantiates the repository and gets back the expected result. After this, I am manually setting some properties on the repository class so that it could be used ahead in the future.
But when I hit an controller endpoint for the first time which injects this repository ,
it creates a new instance of the Repository again, but further API hits don't.
What would be the reason the new Repository instance is getting generated 2 times