【发布时间】:2018-11-05 17:09:40
【问题描述】:
这是当前的样本结构
Posts(Collection)
- post1Id : {
viewCount : 100,
likes : 45,
points : 190,
title : "Title",
postType : image/video
url : FileUrl,
createdOn : Timestamp,
createdBy : user20Id,
userName : name,
profilePic: url
}
Users(Collection)
- user1Id(Document):{
postsCount : 10,
userName : name,
profilePic : url
}
viewed(Collection)
- post1Id(Document):{
viewedTime : ""
}
- user2Id(Document)
最终目标是
- 我需要获取当前用户未查看的帖子,并在分页中按降序排列。
有哪些可能的最佳解决方案(例如更改结构、云功能、来自客户端的多个查询)?
【问题讨论】:
-
所以您在
Users(Collection) -> user1Id(Document) -> viewed(Collection)下仅托管用户看过的帖子,并且您希望获取用户未看过的所有帖子,对吗? -
@AlexMamo 是的,这就是我需要的
-
能否发一个更详细的数据库结构,更清楚地看到你的属性?
-
@AlexMamo 添加了更多详细信息
-
对您有帮助的答案,即使这意味着您的数据库结构发生了一些变化?
标签: firebase google-cloud-firestore