我正在尝试为Firestore设计一种社交媒体架构,但是由于Firestore缺少“ in”查询而无法找到一种解决方法,因此遇到了问题。
例如,如果您想要从所关注的人那里获取帖子的提要,则无法执行“ {user1,user2,...}中的位置。orderBy(“ timestamp”)。limit(num)“ 。是否有非客户端解决方案。
我考虑了以下解决方案: 1.每个帖子都包含按照UID数组关注它们的用户。这可能有效,但效率很低,因为您随后需要将所有新关注者添加到旧帖子中,并且用户可能有数千个关注者。
我似乎在任何地方都找不到解决方案。 下面是我当前对模式的设计:
**************************
posts: collection
postID: document
postID: string
userID: if user
groupID: if a group
likes: num
dislikes: num
title
body
timestamp: Date
**************************
following: collection
users: document
following: collection
UID: document
userID: $UID
following:boolean
timestamp
groups: document
following: collection
pushID: document
groupID: pushID
following: boolean
timestamp
**************************
followers: Collection
users: document
followers: collection
$UID: document
userID: $UID
following:boolean
timestamp
groups: document
followers: collection
$pushID document
pushID: $pushID
following:boolean
timestamp
**************************
likes: collection
$UID: document
comments: collection
commentID: document
like: boolean
posts: collection
postID: document
like: boolean