Why do I need Mongoose or Mongojs for Node.js?

HaoQi Li picture HaoQi Li · May 5, 2013 · Viewed 15.4k times · Source

Major Questions

Currently I'm very confused, the main questions are: What is the use of Mongoose/Mongojs? What would be different if I run Node.js without Mongoose/Mongojs?

I can't find any good explanation of the big picture of how Mongoose or Mongojs fits together with Node.js.

Mongoose's slogan: "elegant mongodb object modeling for node.js" is not helping.

Minor Questions

Btw, I think Mongoose and Mongojs are doing the same type of thing for Node.js (i.e. interchangeable), but this page seems to be describing Mongojs quite differently from Mongoose: "Simple driver that emulates the mongodb API as much as possible." So I might be wrong in putting Mongoose and Mongojs together. If so, please clarify as well.


Maybe I shouldn't use Mongojs since stackoverflow doesn't even have a tag for it. If so, just ignore everything I said above about Mongojs.


While on the topic of giving the big picture of Node.js with Mongoose and Mongojs, what else on this page should I know?

Thanks.

Answer

Luckylooke picture Luckylooke · Apr 12, 2014

Luis Elizondo said:

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.

http://luiselizondo.net/blogs/luis-elizondo/mongoose-vs-mongojs-nodejs