{
"movies": {
"movie1": {
"genre": "comedy",
"name": "As good as it gets",
"lead": "Jack Nicholson"
},
"movie2": {
"genre": "Horror",
"name": "The Shining",
"lead": "Jack Nicholson"
},
"movie3": {
"genre": "comedy",
"name": "The Mask",
"lead": "Jim Carrey"
}
}
}
Run Code Online (Sandbox Code Playgroud)
我是Firebase的新手.我如何可以检索从上面的数据结果,其中genre = 'comedy'与lead = 'Jack Nicholson'?
我有什么选择?
我有一系列的键导致我的社交网络的帖子对象像/ posts/id /(发布信息)
当我加载帖子时,我使用observeSingleEventOfType(.Value)方法加载/发布/ 0然后/ posts/1等.
我使用lazyTableView一次加载30并且速度很慢.有没有什么方法可以使用其中一种查询方法或其他方法使其更快,即使我必须重构我的JSON树中的数据.
我来自Parse重新实现我的应用程序,到目前为止,经验非常好.只有这一点我有点坚持.在此先感谢您的帮助!
编辑:
func loadNext(i: Int) {
// check if exhists
let ideaPostsRef = Firebase(url: "https://APPURL")
ideaPostsRef.childByAppendingPath(i.description).observeSingleEventOfType(.Value, withBlock: {
(snapshot) in
if i % 29 == 0 && i != 0 && !self.hitNull { return }
// false if nil
// true if not nil
if !(snapshot.value is NSNull) {
let postJSON = snapshot.value as! [String: AnyObject]
print("GOT VALID \(postJSON)")
let post = IdeaPost(message: postJSON["message"] as! String, byUser: postJSON["user"] as! String, withId: i.description)
post.upvotes …Run Code Online (Sandbox Code Playgroud)