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

查看:100
本文介绍了一个应用程序中有多个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.

希望它将对您有所帮助!祝你好运!

Hope that it will help you! Good luck!

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

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