Comments (6)
I did not found a solution, so I have to stay with typegoose beta.9
and mongoose 5.12.8
from nestjs-typegoose.
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.
from nestjs-typegoose.
@GuillaumeGSO You did the same mistake as I did:
@Module({
imports: [
TypegooseModule.forRoot(config.mongoURI), CompanyDataModule, NotificationsModule],
controllers: [
AppController, // Should be there since it is AppModule's responsibility to instantiate this.
NotificationsController // Should NOT be here since it is NOT AppModule's responsibility to instantiate this.
],
providers: [
AppService,// Should be there since it is AppModule's responsibility to instantiate this.
CompanyDataService, // Should NOT be here since it is NOT AppModule's responsibility to instantiate this. However since this one doesnt have any deps, it doesnt crash. It will be instantiated twice though.
NotificationService, // Should NOT be here since it is NOT AppModule's responsibility to instantiate this.
NotificationDataService // Should NOT be here since it is NOT AppModule's responsibility to instantiate this.
],
})
export class AppModule {}
Including services and controllers into the controllers
and providers
will make Nest try to instantiate them from that module (here AppModule
, which should not instantiate them, but merely import them from NotificationModule
).
Only NotificationModule
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.
from nestjs-typegoose.
Hello, could you solve it? I have the same error
Do you have a version that I can try in my package to solve the problem at least until there is a solution?
from nestjs-typegoose.
Hi, i have a similar problem on a very simple training project.
@OoDeLally : fell free to have a look on this branch : https://github.com/GuillaumeGSO/notifications-project/tree/adding_mongodb
I've been stucked on this for hours now....
My model is NotificationData but the error keep using NotificationDataModel
@InjectModel(NotificationData)
Error: Nest can't resolve dependencies of the NotificationDataService (?). Please make sure
that the argument NotificationDataModel at index [0] is available in the AppModule context.
from nestjs-typegoose.
Thank you so much !
Just few lines and you saved my day !
from nestjs-typegoose.
Related Issues (20)
- Controller passes the test whereas the services level test don't
- Models with the same name HOT 1
- some error
- Incompatibility with the typegoose model
- Typegoose library hook errors.....Generic type HOT 2
- Dependency Injection Inside a Pre save hook HOT 1
- Support/ update to NestJS v8 and others HOT 17
- Discriminator properties not working, only base class.
- MongooseError: Operation `xxx.find()` buffering timed out after 10000ms
- Mongoose version 6.0.5, without usenewurlparser parameter
- Mongoose 6.x Support Issue - no exported member 'ConnectionOptions' HOT 1
- replace Promises with Observables HOT 1
- 'useNewUrlParser' does not exist in type 'TypegooseConnectionOptions' HOT 4
- Can not install module HOT 5
- Dependency Dashboard
- Package maintenance HOT 5
- Using the same models in InjectModel HOT 1
- InjectConnection not supported?
- Not support new @nestjs/common 10 version HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nestjs-typegoose.