That way your db will throw an error when you insert a shorturl or longurl that is already in the db. Also I think you could do your url validation in mongoose by creating an your own schema type. http://mongoosejs.com/docs/customschematypes.html
another thing is either to hide your connection string. i.e require the string in and put it in .gitignore because from my home I can get into your heroku db
Thanks for the taking your time looking at my code!
Yeah I’ve definetaly over-thought the logic behind this. I think I was trying to make it like a relational-database, which is probably why I made two collections instead.
Doh! I forgot about hiding the mongodb connection. I knew I was missing something…