Hello everyone, I am currently doing a project that simulates planets and launches in nasa. have a problem when I try to implement the SaveLaunch function and save a launch, I get the following error:
I did required the collection of the planets from my mongo in the current file
I would really appriciate if you could help me understand and solve this problem, unfortunately i didn’t find anything on the internet.
What does the code look like? Looks like you’re calling findOne on the wrong object as whatever you’re calling it on does not have that method available.
this is how the function looks like
And what is planets? Where is the definition of that?
planets only have names and i’ve imported them to mongo succesfully from csv file, I wanted to handle a case if I try to create a launch(that has planets as destinations) with a planet that doesn’t exist, that it won’t let me create the launch. this how the schema of planet and the definition looks like
I’ve not used Mongoose that much personally but take a look at this SO article which seems to be similar:
Something else to try is to set a breakpoint on that line and check what the signatures of the object in question look like and debug it.
Also, do you have a circular dependency from that warning?
If you can push code to a temporary repo somewhere it may be easier to debug / view for people.
I have faced the same issue with this problem. the issue lies in your launch object, If you rename the property called destination to the target in your launch object it will be resolved.