You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exportabstractclassBaseRepository<TextendsBaseModel>{protectedreadonlycollection: Collection<T>constructor( @InjectprivatereadonlyconnectionManager: ConnectionManager){//# Weird -- Why can't I inject this in this constructor, instead?//const connectionManager = Container.get( ConnectionManager );//TypeError: Cannot read property 'db' of undefinedthis.collection=this.connectionManager.db.collection(this.getCollectionName())}abstractgetCollectionName(): string;}
@SingletonexportclassTileRepositoryextendsBaseRepository<Tile>{getCollectionName(){return'tiles';}test(){console.log(this.collection.collectionName);}}
I've tried several variations of the constructor including a simple @Inject connectionManager: ConnectionManager to no avail. I've also tried field injection, and that didn't work, but I suspect that information wouldn't be available in the constructor anyhow.
If I add a constructor in TileRepository and @Inject the ConnectionManager, then pass it to super() it will work, but I don't want to lead that implementation detail.
The text was updated successfully, but these errors were encountered:
"typescript-ioc": "^3.2.2"
I've tried several variations of the constructor including a simple
@Inject connectionManager: ConnectionManager
to no avail. I've also tried field injection, and that didn't work, but I suspect that information wouldn't be available in the constructor anyhow.If I add a constructor in
TileRepository
and@Inject
theConnectionManager
, then pass it tosuper()
it will work, but I don't want to lead that implementation detail.The text was updated successfully, but these errors were encountered: