The problem might be coming from the collection name
I’ll try to put an “s” at the end of the collection name…
Mongoose automatically looks for an “s” at the end of the collection… so… apparently mongoose might be creating an empty collection with an “s” at the end, and showing me an empty array… this is annoying… .
You should be able to interact with your mongoDB either with mongo shell (for local installations) or through the interface at mongodb.com if you’re using an atlas db. So, you can put some docs in the database and then query for them and you should see what you put in the database in your app if you output them. You can also query for collections via mongoose to make sure you’re using the one you expect. Conversely, if you save some data via your app, it should show up in atlas or mongo shell too.
The only code problem that leaps out is
According to the docs, find() apparently requires a filter, even if empty (or maybe undefined is a good enough object for it…). You could always add some logging to your catch callback if you think you are missing the response:
You could also add some logging to your /part route and have it log the route inputs and just log ‘hello’ or something from your then() callback to make sure it’s executing. Once you’re sure the code path is going where you think it’s going it may be easier to diagnose the mongoDB problems.
for this one I had to do some modifications to the Schema file… seems like I would run into different problems if my MongoDB collection doesn’t have an “s” at the end…
If I want to work naming my collection without the “s” at the end… then I have to implement a code like this… notice I am using mongoose.pluralize(null); plus I have to use the const part with a small “p”, else mongoose would once again create another collection with a capital “P”…