A couple facts about three cool technologies
- node.js is a powerful way of writing backend code in JavaScript; why JavaScript? Because you have the kind of problem that benefits from asynchronous code (the average web app) and you like using the same brain for backend and frontend work
- mongoDB is an awesome NoSQL data store for objects. It is an especially great companion to JavaScript since its internal storage are JSON-objects. JSON has plays particularly well with JavaScript due to certain similarities (some even think the JSON language is a subset of JavaScript, although it's not)
- Heroku is the simplest way to deploy web apps. Originally designed for Ruby, it gained node.js support last spring/summer. There are alternatives, but heroku presents itself as a particularly good pick for various reasons (it feels right)
Combining these three technologies should be a walk in the park. The best thing since sliced bread and unicorn farts should rain down the heavens upon you for even thinking of using node.js, mongo and heroku in unison.
Not so much.
The culprit - the bleeding edge, baby!
Mongo's only been widely-ish popular for a year, node.js still isn't widely and Heroku is traditionally a RoR hosting environment so there are things that aren't quite smooth yet.
Getting mongoDB support on Heroku means using an external party - what heroku calls an add-on - MongoHQ. It's a mongoDB hosting provider that gives you access to a database and lets you loose.
But MongoHQ requires authentication.
My favourite mongoDB driver for node.js ... doesn't support authentication. At least it doesn't support authentication easily, in fact it doesn't support authentication so much that it isn't officially documented. The only reference to getting this working is some guy's blogpost from April 2011. This is an actively developed library by the way, the last commit to node-mongodb-native's github was yesterday.
Some say I should be using mongoose instead, but that would most likely require rewriting the whole application at this point. Not to mention I don't like mongoose's ORM-like approach because that's just a little too SQL for my liking. Why would you force a traditional data store way of doing things onto something as refreshing as Mongo?
To make things worse, a while ago (about a year it seems), mongo introduced a new mongo:// url schema for connecting to their database ... not even all the official drivers support it yet.
Don't you just love the bleeding edge? Competing libraries, standards shifting under your feet and things never quite working out!
Continue reading about Heroku, mongo, node.js - a problem
Semantically similar articles hand-picked by GPT-4
- First impressions of Rails as a Javascripter
- My very own daily WTF
- Hard work is a total waste of time
- A lesson about client-side templating
- Single page web apps: the worst of both worlds
Learned something new?
Read more Software Engineering Lessons from Production
I write articles with real insight into the career and skills of a modern software engineer. "Raw and honest from the heart!" as one reader described them. Fueled by lessons learned over 20 years of building production code for side-projects, small businesses, and hyper growth startups. Both successful and not.
Subscribe below 👇
Software Engineering Lessons from Production
Join Swizec's Newsletter and get insightful emails 💌 on mindsets, tactics, and technical skills for your career. Real lessons from building production software. No bullshit.
"Man, love your simple writing! Yours is the only newsletter I open and only blog that I give a fuck to read & scroll till the end. And wow always take away lessons with me. Inspiring! And very relatable. 👌"
Have a burning question that you think I can answer? Hit me up on twitter and I'll do my best.
Who am I and who do I help? I'm Swizec Teller and I turn coders into engineers with "Raw and honest from the heart!" writing. No bullshit. Real insights into the career and skills of a modern software engineer.
Want to become a true senior engineer? Take ownership, have autonomy, and be a force multiplier on your team. The Senior Engineer Mindset ebook can help 👉 swizec.com/senior-mindset. These are the shifts in mindset that unlocked my career.
Curious about Serverless and the modern backend? Check out Serverless Handbook, for frontend engineers 👉 ServerlessHandbook.dev
Want to Stop copy pasting D3 examples and create data visualizations of your own? Learn how to build scalable dataviz React components your whole team can understand with React for Data Visualization
Want to get my best emails on JavaScript, React, Serverless, Fullstack Web, or Indie Hacking? Check out swizec.com/collections
Did someone amazing share this letter with you? Wonderful! You can sign up for my weekly letters for software engineers on their path to greatness, here: swizec.com/blog
Want to brush up on your modern JavaScript syntax? Check out my interactive cheatsheet: es6cheatsheet.com
By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️