我正在使用Firebase在iOS应用程序中制作论坛式应用程序,我想知道是否有什么我可以做的来改善我的数据库结构。我担心的是"家"。部分,其中每个帖子将需要2个api调用来接收海报的图像URL。如果有1000个帖子,则每个用户每次刷新将调用2000个api。
Login: 1-3 calls
- CheckUsers: 1-3个firestore调用,具体取决于用户是否存在让用户
- 保存用户/创建用户
- 设置组
Home: 1 Firestore call + 1 Firestore call/post + 1 Storage call/post(如果没有缓存)
- retrievePost ():
- Get All Posts: 1 firestore call
- For循环
- 获取用户缩略图:每个帖子1个firestore调用
- 加载图像:每个帖子1个存储调用(图像被缓存)
Add Reply: 3 calls
- 在Post文档中添加回复收集文档:1 firestore call
- 将"replies"字段增加1:1 firestore调用
- 为用户DB: 1 firestore call添加回复post ID
Add Post: 1 call
- Add Post to DB: 1 firestore call
Like/different Post: 1 call
- 添加/删除数组:1 firestore call
Account: 1 Firestore call + 1 Storage call
- 更新用户DP:
- 上传图像到存储:1存储调用
- 设置图片URL为用户DB: 1 firestore call
您可以创建一个本地临时字典,该字典将每个帖子的用户ID映射为个人资料图片URL。这样,如果一个人多次发布,它只会在第一次调用API。
另外,添加分页,这样您就不会一次加载1k个帖子