Why does we need, what advantages to use Mongoose

Source: Internet
Author: User
Tags mongo shell

Question

I have the just started mongodb up with and I recently gone through Mongoose , the an ODM framework.

On the documentation, I couldn ' t find why do we need to use Mongoose . One reason I can give is the we can define application schema from Mongoose .

I am looking for more possible reasons, and needs that would attract me to use Mongoose .

Please list all possible advantages and reasons/needs Mongoose .

Some voice:

(1), Main Advantage is abstraction on top of pure MONGO.

Many developers come from SQL database types, and feel very uncomfortable working with dynamic collections that has no an Y structure defined. So Schemas on first place helps with that.
Additionally to the IT implements validation and other neat features in order to make sure your schema was well satisfied When inserting/updating/finding documents from collections.

It as well creates Model abstraction which makes it easier to work with, so it looks like you is working with Ju St objects rather than pure data.

There is more concepts like middleware, plugins, population, validation and more, ple ASE Check here:http://mongoosejs.com/docs/guide.html

Personally, I prefer mongo-native as it is more consistent with official 10gen MONGO docs and does not creates abstraction s that all cost of some limits and rules so you'll have the to follow.

(2), If you is working with node. JS and you are pretty new NoSQL I ' d recommend using the the native Node Driver (MongoDB) A T first.

Reasons:

1) The syntax between the Node Driver and the Mongo shell is very similar and so you'll get a quicker grasp of how to use M Ongodb in general.

2) Models is only useful if you were scaling into a big application with a large API that needs to being broken up into a mVC System (Mongoose being your models).

Pros/cons of using Mongoose:

Pros:

    • Biggest Pro is the it have the data validation built into it (requirements of the "what data" you'll allow to being added or to up Date your database). It'll take the some work to build that yourself. (but not so hard)
    • It would abstract away most of the MongoDB code from the rest of the application.

Cons

    • Biggest con is starting off with schemas right out of the gate would really defeat the purpose of using NoSQL and it would b E hard-to-experience what's good about having a loose structured data system during the stages of rapid development.

    • Not all of your data operations would nicely fit into a characterization so can encapsulated with a model. Encapsulation is especially hard initially-unless you had a very clear idea of the data flow before you start (which are idea L, but is not easy to be building something conceptually new and requires a lot of experimentation and change/redesign ).

See: Https://www.quora.com/Node-js/Node-js-Whats-the-advantages-of-using-MongoDB-Mongoose

Why does we need, what advantages to use Mongoose

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.