为什么需要,使用猫鼬有什么好处 [英] Why do we need, what advantages to use mongoose

查看:28
本文介绍了为什么需要,使用猫鼬有什么好处的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用 mongodb,最近我浏览了 Mongoose,一个 ODM 框架.

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

在文档中,我找不到为什么我们需要使用 Mongoose.我可以给出的一个原因是我们可以从 Mongoose 定义应用程序模式.

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

我正在寻找更多可能的原因,以及吸引我使用 Mongoose 的需求.

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

请列出使用 Mongoose 的所有可能的优势和原因/需求.

Please list all possible advantages and reasons/needs why use Mongoose.

推荐答案

与纯 mongo 相比,主要优势是抽象.

Main advantage is abstraction over pure mongo.

许多来自 SQL 数据库类型的开发人员在处理没有定义结构的动态集合时感到非常不舒服.因此,架构首先有助于实现这一点.
此外,它还实现了验证和其他简洁的功能,以确保在从集合中插入/更新/查找文档时您的架构是一致的.

Many developers who come from SQL database types feel very uncomfortable working with dynamic collections that have no structure defined. So Schemas in the first place helps with that.
Additionally, it implements validation and other neat features in order to make sure your schema is consistent when inserting/updating/finding documents from collections.

它还创建了模型抽象,使其更易于使用,因此看起来您只是在处理对象而不是纯数据.

It also creates Model abstraction which makes it easier to work with, so it looks like you are working with just objects rather than pure data.

还有许多其他好东西,例如中间件插件人口验证.请查看 mongoose 文档了解更多信息:

There are many other goodies like middleware, plugins, population, validation. Please check mongoose docs for more information:

就我个人而言,我更喜欢纯 mongo,因为它与官方 10gen mongo 文档更一致,并且不会创建总是需要遵循一些限制和规则的抽象.

Personally, I prefer pure mongo as it is more consistent with official 10gen mongo docs and does not create abstractions that always costs some limits and rules that you will have to follow.

这篇关于为什么需要,使用猫鼬有什么好处的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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