InjectModel brake on mongoose 5.12.9 and higher
See original GitHub issueHi, I’m testing latest typegoose@beta.11
with mongoose 5.12.9
(tested also with 5.12.10
and 5.12.12
) but the InjectModel
got breaked.
constructor(
@InjectModel(Account)
private readonly accountModel: ReturnModelType<typeof Account>
) {
super(accountModel);
console.log(accountModel); // Model { undefined } => typegoose beta.10+ and mongoose 5.12.9+
Model { Account } => typegoose beta.9 and mongoose 5.12.8
}
I have tried several combination of typegoose and mongoose and I can say that the maximum supported versions are typegoose beta.9
and mongoose 5.12.8
. InjectModel stop working from mongoose 5.12.9
and higher.
To be noted that from typegoose beta.10
the minimum supported version of mongoose is 5.12.9
so I can’t upgrade typegoose too.
Thanks in advance
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
Issues · kpfromer/nestjs-typegoose - GitHub
Mongoose 6.x Support Issue - no exported member 'ConnectionOptions'. #452 opened on Nov 3, ... InjectModel brake on mongoose 5.12.9 and higher.
Read more >5.12.9 - mongoose - npm
mongoose. TypeScript icon, indicating that this package has built-in type declarations. 5.12.9 • Public • Published a year ago.
Read more >nestjs-typegoose - Bountysource
Hi, I'm testing latest typegoose@beta.11 with mongoose 5.12.9 (tested also with 5.12.10 and 5.12.12 ) but the InjectModel got breaked.
Read more >How to inject model if the model is in the root module only
Just do the MongooseModule.forFeature import in the same module as the forRoot import. :-) – Kim Kern. Dec 10, 2018 at 16: ...
Read more >Mongoose v6.8.1: API docs
When nesting schemas, ( children in the example above), always declare the ... they have the potential to break Mongoose/ Mongoose plugins functionality....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@GuillaumeGSO You did the same mistake as I did:
Including services and controllers into the
controllers
andproviders
will make Nest try to instantiate them from that module (hereAppModule
, which should not instantiate them, but merely import them fromNotificationModule
). OnlyNotificationModule
does have the required dependencies, and you only need to instanciate them from this module.Remove the commented lines above, and your code will run.
I had a similar problem, and my mistake was a combination of various bad dependencies. A - I was trying to export the model, instead of exporting the service. or B- I was exporting the service, but was including the service into the user’s
providers
(which leads to a double-instantiation). If you can create a minimal example, I can have a look, in case you made the same kind of mistakes.