URL Shortener Microservice - MONGODB problems

Hi guys,

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.

Link to the challenge:

You need to first look at the server log under Tools which currently shows an error that must be resolved first. Once you fix that, you will also need to fix something else on the same line.

Can you show us your MONBO_DB string (minus the password) contained in the .env file?

yea there is the string


atlasmongo gave me this but it didnt work


Thanks for any help

Make sure to surround the string with single quotes.

Also, I recommend updating the the mongodb and mongoose libraries to:

    "mongodb": "^3.2.6",
    "mongoose": "^5.6.4",

Also, take a look at the Install and Set Up Mongoose challenge for the proper connection syntax.

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?

What errors do you see in the server log?

@laufmartin OK, I think I figured out what the problem is. You had an issue in the following line:

urlSchema.plugin(autoIncrement.plugin, { model: 'UrlShortener', field: "shortUrl"});

It should actually be:

urlSchema.plugin(autoIncrement.plugin, 'UrlShortener');

Hi, after dependencies change it thrown:
WARNING: The useMongoClient option is no longer necessary in mongoose 5.x, please remove it.

and error was:
TypeError: connection.model is not a function

I tried to change autoIncrement plugin as you suggested but result was the same

It looks like I need to start from the scratch :frowning:

Let me take a look at your latest changes on Glitch and get back with you.

thank you very mich for all the effort. I left it like before and there is no error in log now. You can edit as well:

I guess it’s doing something…I can monitor some activity on my cluster


The link you posted does not work.

I remixed your original and made the changes I suggested.

that is strage it should I generated inside glitch. Is it only one shot link?

This is another one

All I know, is the link should look something like:


I used this feature of glitch to create previous link


there is the link you mentioned above

When I try to run your latest version using a url which looks like the following, I get an error because of the version of mongo you are using in the package.json. If I switch it to a newer version, then I do not get the error.


Are you using mongodb+srv or mongodb?

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)
let connection = mongoose.connect(mongo_key, { useMongoClient: true });

Change the line above to match the syntax shown in the Install and Set Up Mongoose.

Also, you still have not implemented the change I suggested above regarding the userSchema.plugin line.

I did everything you mentioned above but that is what I got


8:03 PM

throw ex;

8:03 PM


8:03 PM

8:03 PM

TypeError: connection.model is not a function

8:03 PM

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)

8:03 PM

at Module.load (module.js:566:32)

8:03 PM

at tryModuleLoad (module.js:506:12)

8:03 PM

at Function.Module._load (module.js:498:3)

8:03 PM

at Function.Module.runMain (module.js:694:10)

8:03 PM

at startup (bootstrap_node.js:204:16)

8:03 PM

at bootstrap_node.js:625:3

8:03 PM

2 minutes ago