English 中文(简体)
消防基地应当服务器或客户进行过滤
原标题:Firebase should server or client do the filtering

I am writing a polling app with a Firebase backend. Users answer to yes/no questions and see results. They can t see who answered the question though, only their friends can.

questions
    question1:
        readable
           text: "Do you enjoy Stack Overflow?"
           yes_count: 76
           no_count: 14
        response:
            user1: yes
            user2: no
            ...
            user1000: no

users:
    user1:
        friends:
            user1
            user999

这样做的一个办法是在<条码>上打上<条码>。 这可能导致下载数千个不必要的国际数据库。

另一种办法是要求服务器这样做。 用户要求让朋友UIDs在座,而后台则进行过滤,并将结果放在用户能够聆听的地方。 但这是一个巨大的额外负担,特别是考虑到只要对一个问题有新的答案,支持者必须检查每个用户是否由朋友回答。

我如何在<代码>response node上询问消防基地只让朋友UIDs,而不是每个人都知道?

如果无法做到这一点,用户是否最好进行过滤(和下载数千个不需要的电子数据),或者服务器进行过滤(额外负荷)?

最佳回答

This becomes trivial once you require that friendships are bi-directional, so also store the reverse relationship. E.g.

friends:
    user1:
        user42
        user999
    user42:
        user1
    user999:
        user1

With this bidirectional data structure, if a user posts you can simply load their friend list with /friends/$uid and loop over that. No expensive query needed.

问题回答

暂无回答




相关问题
what is wrong with this mysql code

$db_user="root"; $db_host="localhost"; $db_password="root"; $db_name = "fayer"; $conn = mysqli_connect($db_host,$db_user,$db_password,$db_name) or die ("couldn t connect to server"); // perform query ...

Users asking for denormalized database

I am in the early stages of developing a database-driven system and the largest part of the system revolves around an inheritance type of relationship. There is a parent entity with about 10 columns ...

Easiest way to deal with sample data in Java web apps?

I m writing a Java web app in my free time to learn more about development. I m using the Stripes framework and eventually intend to use hibernate and MySQL For the moment, whilst creating the pages ...

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

How can I know if such value exists in database? (ADO.NET)

For example, I have a table, and there is a column named Tags . I want to know if value programming exists in this column. How can I do this in ADO.NET? I did this: OleDbCommand cmd = new ...

Convert date to string upon saving a doctrine record

I m trying to migrate one of my PHP projects to Doctrine. I ve never used it before so there are a few things I don t understand. In my current code, I have a class similar to this: class ...

热门标签