Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

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

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

Problem

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.

Problem courtesy of: HaoQi Li

Solution

If you're not using MongoDB, the database, then there is no need to have any type of driver/odm solution. Nodejs will run just fine without these.

If you are attempting to connect to a MongoDB database instance, then you will need some sort of driver. I have never heard of a MongoJS, but maybe you are referring to the MongoDB driver? This driver will help you communicate with the database, such as saving documents or retrieving them.

MongooseJS is an object modeling library. It sits on top of the MongoDB driver and manages relationships and object mapping. It can detect changed properties in objects, and then run validation and update operations.

Long story short: You don't need to explicitly install both, as Mongoose will include the MongoDB driver when installing through NPM. You don't need either if you are not connecting to a mongodb database.

Solution courtesy of: Tyler Shaddix

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

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

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×