【发布时间】:2019-06-10 13:21:48
【问题描述】:
所以我想创建一种社交媒体应用程序并使用 firestore 作为主数据库。
目标是创建“facebook”新闻提要。
每个用户都有一个朋友列表,每个用户都可以创建帖子。
每个帖子都可以修改为对应用程序的所有用户或用户朋友可见。因此,每个用户都可以向他的所有朋友发布帖子,也可以向应用程序中的每个人发布帖子。
此外,用户可以在新闻源中“保存”他们喜欢的帖子。(LikedPosts 子集合)
USERS (collection)
DocumentID - userId gathered from Authentication uid
firstName: String
lastName: String
username: String
birthdate: Timestamp
accountCreationDate: Timestamp
FRIENDS (subcollection)
DocumentID - userId of the friend
username: String
LikedPosts (subcollection)
authorUserId: String
authorUsername: String
text: String
imagePath: String
POSTS (collection)
DocumentID - postId randomly generated
authorUserId: String
authorUsername: String
text: String
imagePath: String
likesCount: Number
forFriendsOnly:yes
LIKES (subcollection)
DocumentID - userID of the liker
username: String
现在在用户的新闻源中 - 我如何查询所有可见帖子 (forFriendsOnly:no) 以及仅限朋友的所有帖子,当前用户在作者朋友子集合中。
另外,如果用户更改了他的名字,我怎样才能为他以前的所有帖子以及与该用户相关的所有保存帖子相应地更改他的名字?(位于用户喜欢的帖子子集合中)
【问题讨论】:
标签: firebase google-cloud-firestore