【发布时间】:2016-11-29 04:33:53
【问题描述】:
我有 Instagram 之类的应用。 我有firebase作为后端:
post 节点 - 包含来自不同用户的所有帖子 [post_id post_user post_name post_content]
问题: 我只想从我关注的用户那里获取帖子。
我的步骤:
-
我在数组中得到了以下 users_id 的列表
followersIds -
我想知道我是否可以像这样查询
getFollowersList { (followersIds) in print(followersIds) self.postRef.queryOrdered(byChild: "user").queryEqual(toValue: followersIds).queryLimited(toLast: limit).observeSingleEvent(of: .value, with: { (snapshot) in if snapshot.value is NSNull { completion(nil); return} else { let dict = snapshot.value as! [String:Any] self.mapDictionaryToArrayOfPost(dict: dict, completion: { (posts) in completion(posts) }) } }) { (error) in debugPrint(error.localizedDescription) } }
问题: Firebase 不能接受数组作为 queryEqual() 中的参数
我可以通过在应用程序中进行过滤来进行此过滤,但我想查询 firebase 并获得结果。 因为在应用中过滤不是一件好事。
任何建议。
【问题讨论】:
标签: ios swift firebase firebase-realtime-database