Firebase database Not equal request - Alternative solution (for iOS)

后端 未结 1 562
别跟我提以往
别跟我提以往 2020-12-11 11:41

I am using Firebase database with a Json structure to manage users\' comments.

 {
    \"post-comments\" : {
            \"post-id-1\" : {
              \"com         


        
相关标签:
1条回答
  • 2020-12-11 12:30

    The first solution is to load the comments via .ChildAdded and ignore the ones with the current user_id

    let commentsRef = self.myRootRef.childByAppendingPath("comments")
    
    commentsRef.observeEventType(.ChildAdded, withBlock: { snapshot in
    
      let uid = snapshot.value["uid"] as! String
      if uid != current_uid {
        //do stuff
      }            
    })
    

    You could expand on this and load everything by .Value and iterate over the children in code as well. That method will depend on how many nodes you are loading - .ChildAdded will be lower memory usage.

    0 讨论(0)
提交回复
热议问题