mongoose vs mongodb(nodejs模块/扩展),哪个更好?为什么呢? [英] mongoose vs mongodb (nodejs modules/extensions), which better? and why?

查看:241
本文介绍了mongoose vs mongodb(nodejs模块/扩展),哪个更好?为什么呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚到Node.js,发现MongoDB有许多库可以使用,最流行的似乎是这两个库:( mongoose和mongodb).我可以了解这些扩展的优缺点吗?除了这两种以外,还有其他更好的选择吗?

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 those extensions? Are there better alternatives to these two?

发现了一个新的库,它看起来也很有趣,它是node-mongolian的,并且是"Mongolian DeadBeef是一个很棒的Mongo DB node.js驱动程序,它试图近似于mongodb shell." (readme.md)

Found a new library that seems also interesting node-mongolian and is "Mongolian DeadBeef is an awesome Mongo DB node.js driver that attempts to closely approximate the mongodb shell." (readme.md)

https://github.com/marcello3d/node-mongolian

这只是为查看此内容的新人添加更多资源,因此基本上蒙古语就像一个ODM ...

This is just to add more resources to new people that view this, so basically Mongolian its like an ODM...

推荐答案

Mongoose是更高级别的,并使用MongoDB驱动程序(这是一个依赖项,请检查package.json),因此在给定这些选项的情况下,您将使用任一种方式.您应该问自己的问题是:我要使用原始驱动程序,还是需要对象文档建模工具?"如果您正在寻找一种对象建模工具(ODM,它是SQL世界中ORM的对应工具),以跳过一些底层工作,那么您希望使用Mongoose.

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.

如果您想要驱动程序,因为您打算破坏ODM可能强制执行的许多规则,请使用MongoDB.如果您想要一个快速的驱动程序,并且可以使用某些缺少的功能,请尝试使用Mongolian DeadBeef: https://github.com/marcello3d /node-mongolian

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

这篇关于mongoose vs mongodb(nodejs模块/扩展),哪个更好?为什么呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆