I have a problem with URL Shortener Microservice Project. I am struggling with MongoDB I guess. I am not even sure if my connection is working. I’ve spent whole weekend with this but my API always freezes or shows nothing.
I have no idea how to correctly work with MongoDB, they changed the connection string syntax now and some other stuff. (https://www.mongodb.com/blog/post/mongodb-3-6-here-to-SRV-you-with-easier-replica-set-connections)
So please if somone can give me some advice where to look and how to understand this mongodb concept
I will be very thankful guys
Your code so far
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36.
I changed it as you recommended but it’s still not working unfortunately. When I press POST URL button, response is correct only regarding URL validity (regex & dns check) but find in DB is obviously not working.
Then I tried to change the dependencies but it stopped working completely…so I am not sure what to do, start once again from the beginning?
I was using just mongodb so I added srv
and then update dependencies
"mongodb": "^3.2.6",
"mongoose": "^5.6.4",
But I see error like this now:
TypeError: connection.model is not a function
at Object.exports.initialize (/rbd/pnpm-volume/3231a0e3-c114-42cd-8803-7a554bc5bc70/node_modules/.registry.npmjs.org/mongoose-auto-increment/5.0.1/node_modules/mongoose-auto-increment/index.js:10:34)
at Object.exports.initialize (/rbd/pnpm-volume/3231a0e3-c114-42cd-8803-7a554bc5bc70/node_modules/.registry.npmjs.org/mongoose-auto-increment/5.0.1/node_modules/mongoose-auto-increment/index.js:10:34)
8:03 PM
Jump Toat Object. (/app/server.js:22:15)
8:03 PM
at Module._compile (module.js:653:30)
8:03 PM
at Object.Module._extensions…js (module.js:664:10)
I copied content of server.js and package.json to my project but I still have same error. That must be my connection string otherwise I really dont understand.
I decided to skip auto-increment plugin and instead of it I ran find function without argument so I could count all records in DB. In case of new posted url, new short url will be count + 1. I tried to generate shorturls randomly but it seemed like not very good approach.
To be honest it was a lot of struggling, me and many other campers would be grateful to have more learning content than just a few challenges. It’s really challenging especially from the beginning of new topic.
For example content like this:
helped me finish D3 visualization quite easily after I watched it.