如何使用Firebase创建公共/私人用户配置文件? [英] How to create public/private user profile with Firebase?

查看:103
本文介绍了如何使用Firebase创建公共/私人用户配置文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用户个人资料像Instagram,用户可以在设置中将其个人资料公开或私有,在这种情况下数据结构如何?

I want to make user profile like Instagram, the user can make his profile public or private in the settings, how data structure would be in this case?

推荐答案

记住-用户将只有您在应用程序中定义的访问级别。

Remember - users will have only the level of access that you define in your app.

您可以在配置文件设置中包含一个字段公开/私有,当您检索配置文件列表时,仅过滤公开

You can have a field within the profile setting for public / private, and when you retrieve the list of profiles, filter for public only

您可以通过多种方式来实现此目的,但这是一个示例,结构化数据

There are many ways you could implement this, but here's an example of how you might structure your data

,那么您只需要以便将所有公开个人资料返回给用户

and then you just need to return all public profiles to your users

使用这种方法,您需要确保在移动记录时在私人和公共记录之间移动记录。另外,您也可以将它们全部放在一棵树中,并具有可见性的附加索引,然后根据该字段进行查询

With this approach you would need to make sure you move records between private and public when you move them. Alternatively, you could have them all in one tree with an addition index on visibiity, and query based on that field

这篇关于如何使用Firebase创建公共/私人用户配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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