Svelte Headless CMS

SQL vs MongoDB

Blog Getting Started

SQL vs MongoDB

A comparison of a simple SQL query vs the complexity of the equivalent page of MongoDB javascript.

Like many devs, I have a love/hate relationship with MongoDB Atlas.

First, and real quick, it's awesomenesses:

  • It's Cloud based so you can have a database sitting behind your Vercel / Netlify deployed Svelte / Next.js website without have to roll any additional infrastructure - a couple of lines of simple code and your are COOKING
  • Scaling It SCALES for you. And we're not talking Supabase style handles-your-sharding-and-just-about-manages-to-scale - it just grows, smoothly
  • Fuzzy indexing means search is so much easier, with better results (it can even handle Vector search now)
  • It's free up to 500MB These factors alone mean it is the go-to for many building modern applications - especially with edge deployed javascript frameworks.

But then, the negatives:

  • Syntax. This is the biggie with MongoDB in general. Querying is so much more complex than writing SQL, often requiring a whole page of javascript vs a few words of SQL (see example). Unless your job has a title like "MongoDB Guy" you won't spend enough time using it to not have to look up how to do everything all over again each time you come back to the database.

And finally, the most annoying MongoDB Atlas Gotcha ever!


Related docs


Download the code for this blog from GitHub at https://github.com/webuildsociety/svelte-headless