新闻提要的 Firebase 扇出结构 [英] Firebase fan-out structure for news feed

查看:9
本文介绍了新闻提要的 Firebase 扇出结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含 postsusers 和其他节点(如经典社交媒体应用)的数据库.

I have a database with posts, users and other nodes like classic social-media app.

我将继续在我的应用程序中实施最佳实践.现在我想重写我的新闻条(我关注的用户帖子(如 Instagram 中的主页标签)).

I'm continuing implementing best-practices to my application. And now I want to rewrite my news strip (posts of users, that I follow (like home tab in Instagram)).

我已经阅读了一些关于 fan-out 策略的信息,现在我对如何正确执行它感到困惑.

I have read some info about fan-out strategy and now I'm confused in how to do it properly.

所以,我有两个机会:

  1. 喜欢这里:每次用户添加新的post,这个post的完整信息将被复制到users-timeline(users news strip)/UID/postId:此用户的所有关注者的完整信息.并且每次编辑都会编辑此 post 的每次提及.

  1. Like here: Every time user adds new post, this post with full information will be copied to users-timeline(users news strip)/UID/postId: FULL INFO to all followers of this user. And every edit will edit each mention of this post.

每次用户添加新的post,这个postID会被复制到user-timeline(users news strip)/UID/postId: true 给这个 user 的所有 followers.而且每次编辑都只会编辑源帖子.

Every time user adds new post, this postID will be copied to user-timeline(users news strip)/UID/postId: true to all followers of this user. And every edit will edit only source post.

Firebase 哪种逻辑更好?

Which logic is better with Firebase?

推荐答案

我建议你使用 David's East 解决方案.正如我在他的帖子中看到的,他使用 Firebase 非规范化和数据扁平化,这是 Firebase 中的最佳常见做法.

I suggest you using David's East solution. As I see in his post, he uses Firebase denormalization and data flatten, which are the best common practices within Firebase.

我还建议您阅读 NoSQL 数据建模技术为复杂应用正确构建 Firebase 数据 为了更好地理解.

I also recommend you reading NoSQL Data Modeling Techniques and Structuring your Firebase Data correctly for a Complex App for a better understanding.

如果你有 SQL 背景,我建议你也看看 David 的 East 教程,适用于 SQL 开发人员的 Firebase 数据库.

If you have a SQL background, I recommend you seeing also David's East tutorial, The Firebase Database For SQL Developers.

这篇关于新闻提要的 Firebase 扇出结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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