简体   繁体   English

激活离线模式时Core Data优于Firebase实时数据库有哪些优势?

[英]What are the advantages of Core Data over Firebase realtime database when offline mode is activated?

My question might seem a bit naive, but as a beginner iOS developer, I'm starting to think that Core Data is replaceable by firebase realtime database (or firestore in the future). 我的问题可能看起来有点幼稚,但作为初学iOS开发人员,我开始认为Core Data可以被firebase实时数据库(或将来的firestore)替换。 I used both of them in two seperate projects and after activating the offline feature in firebase, I got the same results (that is, the data was saved to the device without the need for an internet connection). 我在两个单独的项目中使用它们,在激活firebase中的离线功能后,我得到了相同的结果(即,数据保存到设备而无需互联网连接)。 I think I read something in the firebase documentation about it not being able to filter and sort at the same time which would probably mean that Core Data can be more convenient for complex queries. 我想我在firebase文档中读到了一些关于它无法同时进行过滤和排序的内容,这可能意味着Core Data可以更方便地进行复杂查询。 It would be great to have some senior developers' views on this subject. 有一些高级开发人员对这个问题的看法会很棒。 Thanks in advance. 提前致谢。

The question is a bit off-topic for SO (IMO) and is (kind of) asking for opinions but it may be worth a high-level answer. 这个问题对于SO(IMO)来说有点偏离主题,并且(有点)要求提出意见,但它可能值得高级答案。 I use both platforms daily. 我每天都使用这两个平台。

Core Data and Firebase are two unrelated platforms used to (manage and) store data; Core Data和Firebase是用于(管理和)存储数据的两个不相关的平台; it's hard to directly compare them without understanding your use case. 在不了解您的用例的情况下直接比较它们很难。

CD is a framework used to model objects in your app. CD是用于为应用程序中的对象建模的框架。 It's the 'front end' of data storage, where the 'back end' could be SQL, flat files, plists etc. It's more of a single user concept which stores data locally on the device (it has cloud functionality but that's a different topic). 它是数据存储的“前端”,其中“后端”可以是SQL,平面文件,plist等。它更像是一个单一的用户概念,它将数据本地存储在设备上(它具有云功能,但这是一个不同的主题) )。

Firebase on the other hand is a live, event driven, cloud based, multi user capable NoSQL storage. 另一方面,Firebase是一个实时,事件驱动,基于云,多用户的NoSQL存储。 While it offers off-line persistence, that's really for situations where you need to be interacting with data when the device is temporarily disconnected from the internet. 虽然它提供了离线持久性,但实际上,当设备暂时与互联网断开连接时,您需要与数据进行交互。

It is not correct that: 这是正确的:

firebase documentation about it not being able to filter and sort at the same time firebase文档关于它无法同时过滤和排序

But, your Firebase structure is dependent on what you want to get out of it - if it's structured correctly, it can be filtered and sorted at the same time in a variety of very powerful (and faaast) ways. 但是,您的Firebase结构取决于您想要从中获取的内容 - 如果它的结构正确,则可以通过各种非常强大(和faaast)的方式同时对其进行过滤和排序。

Core Data is really an incredible technology and building relationships between objects is very straight forward and has SQL-like queries for retrieving data. 核心数据实际上是一种令人难以置信的技术,对象之间的构建关系非常简单,并且具有类似SQL的查询来检索数据。

If you are looking for a database that leverages local storage - go with Core Data or another database that's really strong locally such as Realm, MySql and a number of others. 如果您正在寻找利用本地存储的数据库 - 请使用Core Data或其他本地强大的数据库,例如Realm,MySql和其他许多数据库。

If you want to have Cloud based, multi-user, event driven storage, Firebase is a very strong contender (Realm is another option as well) 如果你想拥有基于云,多用户,事件驱动的存储,Firebase是一个非常强大的竞争者(Realm也是另一个选择)

I would suggest building a very simple To-Do type app and use Firebase for storage in one and then build another using Core data. 我建议构建一个非常简单的To-Do类型应用程序,并使用Firebase存储在一个中,然后使用Core数据构建另一个。 Should only be a couple of hours of work but it will really give you some great basic experience with both - you can make a more informed decision from there. 应该只是几个小时的工作,但它真的会给你一些很好的基本经验 - 你可以从那里做出更明智的决定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM