MongoDB 与 Firebase

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29223835/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 20:21:31  来源:igfitidea点击:

MongoDB vs Firebase

mongodbfirebase

提问by itsclarke

What are some quantitative advantages of using Firebase over MongoDB? (not opinions)

与 MongoDB 相比,使用 Firebase 有哪些量化优势?(不是意见)

I know that Firebase is a cloud based service with it's own API, but I feel like Mongo may give me greater control in the long run.

我知道 Firebase 是一个基于云的服务,它有自己的 API,但我觉得从长远来看,Mongo 可能会给我更大的控制权。

回答by Kirill Slatin

  • Firebaseis a real-time engine with backward connectivity. I.e. you might build a cross-platform app where clients subscribe to events on specific data and server actively informs clients about changes
  • The data layer is hosted for you. Mind that it is highly scalable. It's a nice kickstarter solution. Including auth management
  • Geo-Fire. Real-time geo coordinates solution.
  • Evident drawbacks of Firebase are:
    • You have to pay for it as soon as you start growing
    • You can't host datalayer (if owning data is critical or you develop an app for some separated subnet)
  • Firebase是一个具有反向连接的实时引擎。即您可以构建一个跨平台的应用程序,其中客户端订阅特定数据上的事件,服务器主动通知客户端有关更改
  • 数据层为您托管。请注意,它是高度可扩展的。这是一个不错的 kickstarter 解决方案。包括授权管理
  • 地火。实时地理坐标解决方案。
  • Firebase 的明显缺点是:
    • 你一开始成长就必须付出代价
    • 您不能托管数据层(如果拥有数据很重要,或者您为某个分离的子网开发应用程序)

EDIT: here is a nice articlehow to replace Firebase in your app with Node.js+MongoDb. It shows how much work you would have to do on your own, and explains, IMHO, why a startup (small app) should begin with Firebase (if real-time updates to clients are required) and proceed with MongoDb (in any case self-written solution) if the project keeps evolving

编辑:这是一篇很好的文章,介绍如何使用 Node.js+MongoDb 替换您的应用程序中的 Firebase。它显示了你需要自己做多少工作,并解释了,恕我直言,为什么一个启动(小应用程序)应该从 Firebase 开始(如果需要对客户端进行实时更新)并继续使用 MongoDb(在任何情况下都是自己的) - 书面解决方案)如果项目不断发展

EDIT 2: after being acquired by GoogleFirebase now offers various perks on top of its basic features which you would struggle to build on your own:

编辑 2:在被GoogleFirebase收购后,现在在其基本功能的基础上提供了各种额外的好处,您将很难自己构建这些功能:

  • For development

    • Cloud Messaging: Deliver and receive messages across platforms reliably
    • File Storage: Easy file storage (including iOS)
    • Hosting: deliver static files from Firebase's servers (Included in Free plan)
    • Crash Reporting: Not a full logging service, but crucial help
  • For growth

  • 用于开发

    • 云消息传递:可靠地跨平台传递和接收消息
    • 文件存储:简单的文件存储(包括iOS)
    • 托管:从 Firebase 的服务器提供静态文件(包含在免费计划中)
    • 崩溃报告:不是完整的日志记录服务,而是至关重要的帮助
  • 为了成长

    • 远程配置:即时自定义您的应用程序:适用于 A/B 测试
    • 动态链接:将用户发送到应用内的正确位置
    • 通知:在适当的时候与用户互动

回答by Kees de Kooter

Apples and oranges. Firebase is a Backend-as-a-Service containing identity management, realtime data views and a document database. It runs in the cloud.

苹果和橙子。Firebase 是一种后端即服务,包含身份管理、实时数据视图和文档数据库。它在云端运行。

MongoDB on the other hand is a full fledged database with a rich query language. In principle it runs on your own machine, but there are cloud providers.

另一方面,MongoDB 是一个成熟的数据库,具有丰富的查询语言。原则上它在你自己的机器上运行,但有云提供商。

If you are looking for the database component only MongoDB is much more mature and feature-rich.

如果您正在寻找数据库组件,只有 MongoDB 更加成熟和功能丰富。

回答by byrdr

Firebase is designed for real-time updates. It easily integrates with angular. Both are NoSQL databases. MongoDB can also do this with Angular through Socket.io integration. Meteor.js also makes use of MongoDB with an open socket connection for real-time updates.

Firebase 专为实时更新而设计。它很容易与 angular 集成。两者都是 NoSQL 数据库。MongoDB 也可以通过 Socket.io 集成使用 Angular 做到这一点。Meteor.js 还利用带有开放套接字连接的 MongoDB 进行实时更新。

MongoDB can be run locally, or hosted on many different cloud based providers. Firebase, in my opinion is great for smaller apps, very quick to get up and running. MongoDB is ideal for more robust larger apps, real-time integration is possible but it takes a bit more work.

MongoDB 可以在本地运行,也可以托管在许多不同的基于云的提供商上。Firebase 在我看来非常适合较小的应用程序,可以快速启动和运行。MongoDB 是更强大的大型应用程序的理想选择,实时集成是可能的,但需要做更多的工作。

回答by Ramzi C.

After using Firebase a considerable amount I've come to find something.

在大量使用 Firebase 之后,我找到了一些东西。

If you intend to use it for large, real time apps, it isn't the best choice. It has its own wide array of problems including a bad error handling system and limitations. You will spend significant time trying to understand Firebase and it's kinks. It's also quite easy for a project to become a monolithic thing that goes out of control. MongoDB is a much better choice as far as a backend for a large app goes.

如果您打算将它用于大型实时应用程序,它不是最佳选择。它有自己的一系列问题,包括错误的错误处理系统和局限性。您将花费大量时间尝试了解 Firebase 及其问题。一个项目也很容易成为一个失控的整体。就大型应用程序的后端而言,MongoDB 是一个更好的选择。

However, if you need to make a small app or quickly prototype something, Firebase is a great choice. It'll be incredibly easy way to hit the ground running.

但是,如果您需要制作小型应用程序或快速制作原型,Firebase 是一个不错的选择。这将是非常简单的开始运行的方法。

回答by Thomas David Kehoe

I will answer this question in terms of AngularFire, Firebase's library for Angular.

我将根据 AngularFire(Firebase 的 Angular 库)来回答这个问题。

  1. Tl;dr: superpowers. :-)

  2. AngularFire's three-way data binding. Angular binds the view and the $scope, i.e., what your users do in the view automagically updates in the local variables, and when your JavaScript updates a local variable the view automagically updates. With Firebase the cloud database also updates automagically. You don't need to write $http.get or $http.put requests, the data just updates.

  3. Five-way data binding, and seven-way, nine-way, etc. I made a tic-tac-toe game using AngularFire. Two players can play together, with the two views updating the two $scopes and the cloud database. You could make a game with three or more players, all sharing one Firebase database.

  4. AngularFire's OAuth2 library makes authorization easy with Facebook, GitHub, Google, Twitter, tokens, and passwords.

  5. Double security. You can set up your Angular routes to require authorization, and set up rules in Firebase about who can read and write data.

  6. There's no back end. You don't need to make a server with Node and Express. Running your own server can be a lot of work, require knowing about security, require that someone do something if the server goes down, etc.

  7. Fast. If your server is in San Francisco and the client is in San Jose, fine. But for a client in Bangalore connecting to your server will be slower. Firebase is deployed around the world for fast connections everywhere.

  1. Tl;博士:超能力。:-)

  2. AngularFire 的三向数据绑定。Angular 绑定了视图和 $scope,也就是说,你的用户在视图中所做的事情会自动更新局部变量,当你的 JavaScript 更新局部变量时,视图会自动更新。使用 Firebase,云数据库也会自动更新。您不需要编写 $http.get 或 $http.put 请求,数据只是更新。

  3. 五路数据绑定,七路,九路等。我使用AngularFire制作了一个井字游戏。两个玩家可以一起玩,两个视图更新两个 $scopes 和云数据库。您可以制作一个游戏,让三个或更多玩家共享一个 Firebase 数据库。

  4. AngularFire 的 OAuth2 库使使用 Facebook、GitHub、Google、Twitter、令牌和密码的授权变得容易。

  5. 双重安全。您可以将 Angular 路由设置为需要授权,并在 Firebase 中设置有关谁可以读取和写入数据的规则。

  6. 没有后端。您不需要使用 Node 和 Express 制作服务器。运行您自己的服务器可能需要大量工作,需要了解安全性,需要有人在服务器出现故障时采取措施等。

  7. 快速地。如果您的服务器在旧金山而客户端在圣何塞,那很好。但是对于班加罗尔的客户端来说,连接到您的服务器会更慢。Firebase 部署在世界各地,可在任何地方实现快速连接。

回答by suvankar bose

Firebase is a suite of features .

Firebase 是一套功能。

  • Realtime Database
  • Hosting
  • Authentication
  • Storage
  • Cloud Messaging
  • Remote Config
  • Test Lab
  • Crash Reporting
  • Notifications
  • App Indexing
  • Dynamic Links
  • Invites
  • AdWords
  • AdMob
  • 实时数据库
  • 托管
  • 验证
  • 贮存
  • 云消息
  • 远程配置
  • 测试实验室
  • 崩溃报告
  • 通知
  • 应用索引
  • 动态链接
  • 邀请
  • 广告词
  • 广告

I believe you are trying to compare Firebase Realtime Database with Mongo DB . Firebase Realtime Database stores data as JSON format and syncs to all updates of the data to all clients listening to the data . It abstracts you from all complexity that is needed to setup and scale any database . I will not recommend firebase where you have lot of complex scenarios where aggregation of data is needed .(Queries that need SUM/AVERAGE kind of stuff ) . Though this is recently achievable using Firebase functions . Modeling data in Firebase is tricky . But it is the best way to get you started instantaneously . MongoDB is a database. This give you lot of powerful features. But MongoDB when installed in any platform you need to manage it by yourself .

我相信您正在尝试将 Firebase Realtime Database 与 Mongo DB 进行比较。Firebase 实时数据库将数据存储为 JSON 格式,并将数据的所有更新同步到所有侦听数据的客户端。它将您从设置和扩展任何数据库所需的所有复杂性中抽象出来。我不会推荐 firebase,在那里你有很多需要聚合数据的复杂场景。(需要 SUM/AVERAGE 类型的东西的查询)。虽然这最近可以使用 Firebase 函数来实现。在 Firebase 中建模数据很棘手。但这是让您立即开始的最佳方式。MongoDB 是一个数据库。这为您提供了许多强大的功能。但是 MongoDB 安装在任何平台上都需要您自己管理。

When i try to choose between Firebase or MongoDB(or any DB ) . I try to answer the following .

当我尝试在 Firebase 或 MongoDB(或任何 DB)之间进行选择时。我尝试回答以下问题。

  1. Are there many aggregation queries that gets executed .(Like in case of reporting tool or BI tool ) . If Yes dont go for Firebase
  2. Do i need to perform lot of transaction . (If yes then i would not like to go with firebase) (Tranactions are somewhat easy though after introduction of functions but that is also a overhead if lot of transactions needs to be maintained)
  3. What timeline do i have to get things up and running .(Firebase is very easy to setup and integrate ).
  4. Do i have expertise to scale up the DB and trouble shoot DB related stuffs . (Firebase is more like SAAS so no need to worry about scaleability)
  1. 是否有许多聚合查询被执行。(例如报告工具或 BI 工具)。如果是,请不要使用 Firebase
  2. 我需要进行大量交易吗?(如果是,那么我不想使用 firebase)(虽然在引入功能后,交易有点容易,但如果需要维护大量交易,这也是一种开销)
  3. 我需要什么时间表来启动和运行。(Firebase 非常容易设置和集成)。
  4. 我是否有专业知识来扩展数据库并解决与数据库相关的问题。(Firebase 更像 SAAS,因此无需担心可扩展性)

回答by mnhmilu

Firebase provides some good features like real time change reflection , easy integration of authentication mechanism , and lots of other built-in features for rapid web development. Firebase, really makes Web development so simple that never exists. Firebase database is a fork of MongoDB.

Firebase 提供了一些很好的功能,例如实时更改反射、身份验证机制的轻松集成以及许多其他用于快速 Web 开发的内置功能。Firebase 确实让 Web 开发变得如此简单,以至于从未有过。Firebase 数据库是 MongoDB 的一个分支

What's the advantage of using Firebase over MongoDB?

与 MongoDB 相比,使用 Firebase 有什么优势?

You can take advantage of all built-in features of Firebaseover MongoDB.

您可以利用Firebase所有内置功能而不是 MongoDB。

回答by Nam Kim

In my experience, working with Firebase is a huge advantage if you are trying to do user management, database, messaging sort of app since all of these features are already well integrated.

根据我的经验,如果您正在尝试进行用户管理、数据库、消息传递类的应用程序,那么使用 Firebase 是一个巨大的优势,因为所有这些功能都已经很好地集成了。

Like others have said, if you're just focused on the database/querying aspect, stick to mongo.

就像其他人所说的那样,如果您只关注数据库/查询方面,请坚持使用 mongo。