I'm having a problem which seems a bit hard to put into a title, which is why you've gotten this beast of a title.
I get an error stating: Error: Missing required @inject or @multiInject annotation in: argument 0 in class SceneRepository.
.
This seems simple enough, I should add an @inject
annotation to my first argument. This is my constructor though:
export class SceneRepository extends BaseRepository<IScene> {
constructor(@inject(SceneSchema) private sceneSchema: SceneSchema) {
super(sceneSchema.schema);
}
}
And for the sake of being complete, this is what my BaseRepository looks like:
export class BaseRepository<T extends Document> implements IWrite<T>, IRead<T>{
constructor(private _model: Model<Document>) {
}
...
}
Model<Document>
Comes from a third party library (mongoose).
I have no clue to what I'm doing wrong here, so if you could nudge me in the correct direction, it would be greatly appreciated.
I encountered a similar issue and in my case, instead of constructor injection, I used property injection to get away with this error and also got the injection working.
export class SceneRepository extends BaseRepository<IScene> {
@inject(SceneSchema)
private sceneSchema: SceneSchema;
constructor() {
super(this.sceneSchema.schema);
}
}
Hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.