简体   繁体   English

将Firebase Auth与Firebase实时数据库或Google Cloud Datastore结合在一起?

[英]Combining Firebase Auth with Firebase Realtime Database or Google Cloud Datastore?

I'm planning a web application that requires user auth, plus the ability to display data for the users that is stored in a database. 我正在计划一个需要用户身份验证的Web应用程序,并且需要能够为用户显示存储在数据库中的数据。 No interaction between the users is needed (yet), however the users should be able create objects and query their "own" objects. 用户之间不需要交互(尚未),但是用户应该能够创建对象并查询其“自己的”对象。 For example I list 10 book names (10 book objects), and User A should be able to pick a book and create a new object, call it userNoteObject that contains the name of a choosen book and a short note (that he/she writes). 例如,我列出了10个书名(10个书对象), User A应该能够挑选一本书并创建一个新对象,将其命名为userNoteObject ,其中包含userNoteObject书的名称和一个简短的便笺(他/她写的)。

With a basic pseudo code one book object would look like this: 使用基本的伪代码,一个书本对象将看起来像这样:

bookObj = {"id": 1, "name": "book name"}

And the user's note object would be something like this: 用户的note对象将如下所示:

userNoteObject = {
             "id": 1, 
             "book_name": "random book name", 
             "owner_userid": "a1b2c3d", 
             "note": "some random string"
                  }

With MySQL I would create three tables, one for the users and one for the userNoteObject -s and another for the bookObj -s. 使用MySQL,我将创建三个表,一个用于用户,一个用于userNoteObject -s,另一个用于bookObj -s。 Everytime an user saves a note, I would add it to the table that lists the saved notes. 每次用户保存便笺时,我都会将其添加到列出已保存便笺的表中。 Then I can simply query the notes that belongs to X user based on the user's owner_userid . 然后,我可以根据用户的owner_userid简单地查询属于X用户的owner_userid It's a quite simple functionality. 这是一个非常简单的功能。

After reading about the possibilities I've made a decision to go with Firebase Auth (because in the future I might need Android and iOS compatibility) + Google Cloud Datastore or Firebase Realtime Database . 在了解了可能性之后,我决定使用Firebase Auth (因为将来可能需要Android和iOS兼容性) + Google Cloud DatastoreFirebase Realtime Database However I'm a little bit scared about the Realtime Database of Firebase since I've never worked any DB like it. 但是我对Firebase的实时数据库有些担心,因为我从未像这样工作过任何数据库。 I also like to be able to modify records manually with something like PhpMyAdmin and I assume Cloud Datastore has a visual interface like that. 我还希望能够使用PhpMyAdmin之类的工具手动修改记录,并且我认为Cloud Datastore具有这样的可视界面。

I'm familiar with JSON handling and creating JSON files, however the JSON based database is strange for me at the moment. 我熟悉JSON处理和创建JSON文件,但是目前基于JSON的数据库对我来说很奇怪。 Therefore I'm thinking about that maybe the other option would be a better choice. 因此,我正在考虑也许其他选择是更好的选择。 It's very important that I don't need realtime db features. 我不需要实时数据库功能,这一点非常重要。 I would load X number of entries into the table that holds the bookObj -s and sometimes update them. 我将X个条目的数量加载到保存bookObj -s的表中,有时会更新它们。 I assume when the user creates an userNoteObject it would be saved quickly with both and after deleting an userNoteObject I could refresh the page close to realtime with Datastore. 我假设当用户创建一个userNoteObject ,它将很快被保存,并且删除了userNoteObject我可以使用Datastore接近实时刷新页面。 But the table that holds the book objects must be able to store millions of entries easily. 但是保存书籍对象的表必须能够轻松存储数百万个条目。

So the important things: 所以重要的事情是:

  • One db table should be able to handle millions of records easily 一个数据库表应该能够轻松处理数百万条记录
  • Easy as possible querying 轻松查询
  • Visual interface for the DB (if it's possible) 数据库的可视界面(如果可能)
  • I don't need realtime features like dynamic game score display/saving 我不需要实时功能,例如动态游戏成绩显示/保存

Other info: 其他资讯:

  • I would like to use Angular.js 我想使用Angular.js
  • I'm familiar with Python if it can help in something 我对Python熟悉,如果它可以帮助您

So my question is that which database would be better for my needs? 所以我的问题是哪个数据库更适合我的需求? At the moment I say Datastore, but I'm totally new with these services so I'm not really against the Realtime Database, but Datastore looks more suitable since it has a visual interface. 目前,我说的是数据存储,但是我对这些服务还是陌生的,因此我并不反对实时数据库,但是数据存储看起来更合适,因为它具有可视界面。 However I'm also not sure that how would work Datastore with Firebase. 但是我也不确定如何将数据存储与Firebase一起使用。 If there is a third option like combining both, Realtime Database for the objects save by the user and the static objects for Datastore for example, I would love to hear about it too. 如果有第三种选择,例如将用户保存的对象的实时数据库和数据存储的静态对象结合在一起,那么我也很想听听它。 My overall goal is to be able to write and query the db easy and fast as it's possible and easily use it with Firebase auth. 我的总体目标是能够尽可能轻松地编写和查询数据库,并轻松地将其与Firebase身份验证一起使用。

UPDATE: I just discovered Firebase's Cloud Firestore, so if it can be more useful I could use it. 更新:我刚刚发现了Firebase的Cloud Firestore,所以如果它更有用,我可以使用它。

If you are going to use Firebase I would recommend you use Cloud Firestore instead of either Cloud Datastore or Firebase realtime database. 如果您要使用Firebase,建议您使用Cloud Firestore,而不要使用Cloud Datastore或Firebase实时数据库。 You get the benefits of a real-time database plus a true document based JSON data store. 您将获得实时数据库以及基于真实文档的JSON数据存储的好处。 The one downside is that you don`t have a UI to interact with the data. 缺点是您没有UI与数据进行交互。 Datastore has one but its not as robust as say PHPMyAdmin. 数据存储区只有一个,但不如PHPMyAdmin强大。 And since these are NoSQL datastores SQL support is pretty limited. 而且由于这些是NoSQL数据存储,因此SQL支持非常有限。

If you really want a true relational back-end you could try Cloud SQL which is basically MySQL running on Google Servers. 如果您真的想要一个真正的关系后端,则可以尝试Cloud SQL,它基本上是在Google服务器上运行的MySQL。

For the Firestore console/UI, see https://firebase.google.com/docs/firestore/using-console . 对于Firestore控制台/ UI,请参阅https://firebase.google.com/docs/firestore/using-console Is that the kind of thing you're looking for? 您在找那种东西吗?

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

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