1

How can I retrieve a result from the data where toid is equal to "-LzC6VYgURUZMHy_waYx"

i used this func but it return nil

 func getpagechat(toid:String){
    let mydatabase = FIRDatabase.database().reference().child("message")
    let query = mydatabase.queryOrdered(byChild: "toid").queryEqual(toValue: toid)
    query.observeSingleEvent(of: .value) { (snapshot) in
        print(snapshot)
    }
}

my database

enter image description here

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Firebase Realtime Database queries operate on a flat list of child nodes, and cannot search a hierarchy. Specifically: the value on which you want to order/filter must be at a fixed path under each child node of the location you query on. So in your case, you can search across all messages from one user, but not across the messages from all users. Also see https://stackoverflow.com/questions/27207059/firebase-query-double-nested – Frank van Puffelen Feb 09 '20 at 18:00

0 Answers0