简体   繁体   English

Firebase-读取和获取数据的效率

[英]Firebase - efficiency of reading and fetching data

I'm a little bit worried about my approach on using Firebase, since I'm new to the whole topic. 我有点担心我使用Firebase的方法,因为我是整个话题的新手。

Technically I don't even need a database connection. 从技术上讲,我什至不需要数据库连接。 Everything is saved locally on the phone and nothing has to be fetched realtime. 一切都保存在本地电话中,无需实时获取任何内容。

The only function I wanna provide is for the user to create an account to be able to continuously save his input data to the database and later in case of changing device to fetch this data. 我要提供的唯一功能是为用户创建一个帐户,以便能够将其输入数据连续保存到数据库中,并且以后在更改设备以获取此数据的情况下。

To implement this function, I create a user profile inside of the database for every user that signs up. 为了实现此功能,我在数据库内部为每个注册用户创建了一个用户配置文件。 Every time he adds data, the previously created profile is being updated. 每次他添加数据时,先前创建的配置文件都会被更新。 No fetching so far. 到目前为止没有获取。 In case of logging out, the user's data is being deleted from the phone - since it's possible that somebody else would use the phone. 如果注销,用户的数据将从电话中删除-因为其他人可能会使用电话。 The only time that fetching happens is on log in. 提取发生的唯一时间是登录。
When the user has successfully logged in, the profiles data is being fetched from the database and allocated to the local properties. 用户成功登录后,将从数据库中获取概要文件数据并将其分配给本地属性。

Is this a common approach? 这是常见的方法吗? In case it's bad efficiency wise - I'm open to any suggestion or other approach! 万一效率不好,我可以接受任何建议或其他方法!

I don't see any problem with this approach at all , some developers store large static data in firebase and cache them to avoid the pricing headache of continuously fetching them with every app open , regarding your approach the only thing is that singing in with providers like facebook/google+ may have some miss-synchronized data the logged in user may change his name/profile while open your app and find them old ( this if you have social login in your app ) so you may reload them if this makes sense to your app in each open 我完全看不到这种方法有什么问题,有些开发人员将大量的静态数据存储在Firebase中并进行缓存,以避免在每次打开应用程序时不断获取它们的定价问题,关于您的方法,唯一的问题就是与提供者合作例如facebook / google +可能有一些未同步的数据,登录的用户可能会在打开您的应用时发现其名称/个人资料,并发现它们很旧(如果您的应用中有社交登录名,则可能会变旧),因此如果有意义,您可以重新加载它们您的应用在每次打开时

Plus the user may login 2 devices at the same time so if you have any realtime update it will fail in the old login until the user logouts and logins again 另外,用户可以同时登录2台设备,因此,如果您有任何实时更新,它将在旧的登录中失败,直到用户注销并再次登录

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

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