Firebase newest feed for following users

為{幸葍}努か 提交于 2019-12-04 18:19:56

There's a couple of ways to do this if I am understanding the question correctly.

One way is that instead of storing the user_id, store the user id as a key and the blog id as the value like

users
    facebook:123456789
        blog
            // List of blogs
        following
            user_id_0: blog_id_x
            user_id_1: blog_id_y

Then you can add an observer to each blog in the following node. You can get the path from the key/value pair. In this case Facebook:123456789 is following:

/users/user_id_0/blog/blog_id_x
/users/user_id_1/blog/blog_id_y

Another option would be to create a child node within the following node that contains two values: the user_id and blog_id.

users
    facebook:123456789
        blog
            // List of blogs
        following
            follow_id_0
              userid: user_id_0
              blog: blog_id_0
            follow_id_1
              userid: user_id_0
              blog: blog_id_1

In this case, facebook:123456789 is following user_id_0's blog 0 and blog 1

Note: user_id_0 and user_id_1 are actually Facebook:abcdefg users id's

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!