0

I'm doing a user search in the code below. The return value is user info and user setting. I just want to get only user info. Is this possible?

database model :

  • users
    • userid
      • info

        -name

        -online

      • setting

        • openid
        • email

my code:

let ref = Database.database().reference().child("users").queryOrdered(byChild:"info/name").queryStarting(atValue: text , childKey:"name").queryEnding(atValue: text + "\u{f8ff}" , childKey: "name").queryLimited(toFirst: sonucSayısı)

ref.observeSingleEvent(of: .value, with: { (snapshot) in
    if value == text{
        print(snapshot)
    }
}) { (err) in
    print(err)
}
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
ursan526
  • 485
  • 3
  • 10

1 Answers1

0

The only filtering mechanism is queries, but that will give you a subset of the nodes directly under users.

There is no way to get a subset of each node. If that is required for your use-case, consider splitting your data in two top-level nodes (/userinfos and /usersettings), both using the UID as the key, and then loading it from the one node that is (or both nodes that are) relevant to the use-case.

Also see:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807