mongoose vs mongodb (nodejs modules/extensions), which better? and why?

后端 未结 4 1545
盖世英雄少女心
盖世英雄少女心 2021-01-29 23:20

I\'ve just arrived to Node.js and see that there are many libs to use with the MongoDB, the most popular seem to be these two: (mongoose and mongodb). Can I get pros and cons of

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-29 23:54

    Mongoose is higher level and uses the MongoDB driver (it's a dependency, check the package.json), so you'll be using that either way given those options. The question you should be asking yourself is, "Do I want to use the raw driver, or do I need an object-document modeling tool?" If you're looking for an object modeling (ODM, a counterpart to ORMs from the SQL world) tool to skip some lower level work, you want Mongoose.

    If you want a driver, because you intend to break a lot of rules that an ODM might enforce, go with MongoDB. If you want a fast driver, and can live with some missing features, give Mongolian DeadBeef a try: https://github.com/marcello3d/node-mongolian

提交回复
热议问题