一个应用中的多个 Firebase 项目 [英] Multiple Firebase projects in one app

查看:31
本文介绍了一个应用中的多个 Firebase 项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个应用程序,其中包含任意数量的微型社区".目前一个用户只能属于一个,所以当他们最初注册时,他们输入一个密码,将他们与相关社区相关联.

I'm building an app that has an arbitrary amount of 'micro-communities' on it. Currently a user can only belong to one, so when they initially sign up, they enter a secret code which associates them with the relevant community.

将这些微型社区"(由未来的客户拥有,在应用程序中占有一席之地)分成单独的 Firebase 项目或将所有数据放在一起是否明智?

Is it wise to separate these 'micro-communities' (which are owned by future clients playing for a space on the app) into separate Firebase projects or keep all the data together?

推荐答案

我建议您将所有社区聚集在一起.首先,因为我不确定您是否可以在同一个应用中使用多个 Firebase 项目.

I recommend you to keep all the communities together. First, because I'm not really sure that you can use multiple Firebase Projects in the same app.

我建议你存储这个社区";作为数据库中的项目及其所有当前信息.例如:

I suggest you to store this "communities" as items in your database with all their current info. For example:

{
    "Communities":{
            "CommunityKey1":{
                "communityName":
                "createdDate":
                ....
            }
            "CommunityKey2":{
                "communityName":
                "createdDate":
                ....
            }
            "CommunityKey3":{
                "communityName":
                "createdDate":
                ....
            }
            ....
        }
}

当您将用户添加到数据库时,只需为他们添加一个关联字段currentCommunity"即可.或类似的东西,您可以在其中存储该用户的关联 communityID.然后,当您想过滤一个社区的用户时,只需使用:

And when you add your users to your database, just add them an associated field "currentCommunity" or something like that where you store the associated communityID for that user. Then, when you want to filter the users for one community just use:

FirebaseDatabase.getInstance().getReference().child("users").child("currentCommunity");

您可以在该查询的末尾使用 .equalTo("CommunityID") 过滤其他更多信息.我不是 Firebase 的专家,但我正在做一个类似用户过滤类型的应用程序(使用组而不是社区,他们可以属于多个),最好的方法是使用这个模型.

You can filter else more using .equalTo("CommunityID") at the end of that query. I'm not an expert in Firebase, but I'm doing an app with a similar kind of user filtering(using groups instead of communities and they can belong to more than one), and the best way to do this was using this model.

这篇关于一个应用中的多个 Firebase 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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