< BACK

Mongoose vs mongojs on Node.js

Quick post. I’ve been using Node.js a lot, to be honest, I love it, along with Node, I’ve been using MongoDB which, as you may know if you read my last post, doesn’t support joins.

My first choice on a project was to use mongojs because it was plain simple. It uses the same structure you use on MongoDB directly with a very few exceptions, the main one is the ability to pass a callback as an argument.

I moved really fast with mongojs, but then I hit a wall. Joins. Is just not possible to do it with MongoJS for the same reason you can’t do it with MongoDB, you have to use some sort of black magic to do them, and this is when Mongoose excells.

To be honest, I tried to avoid Mongoose because I thought it was hard to use, defining a model was just “a waste of time” when with MongoJS you don’t need to. I was wrong.

Bottom line. If your project is really simple, no joins, no complicated features, go with MongoJS, is really easy but limited. If you’re trying to save the world with your crazy idea and you need more powers than Superman, spend some time learning Mongoose and use it, it will take you there.

Trust me, I just spent two days rewriting everything using Mongoose, I wish someone told me before.


Share this: