0

I read the Firebase documentation about this, but the documentation conveniently left the detail about equalsTo examples out. I also see some other related questions, but none give me answer about how to filter children with two values.

So the database is more or less like this:

users: {
  as9d8f7a89sdf7a: {
    username: admin,
    password: test123,
    timestamp: 38410238912,
    priviledge: { }
  },
  asd9fasd90f8a0s: {
    username: moderator,
    password: hello456,
    timestamp: 12937129383,
    priviledge: { }
  }
}

I'm looking for something like this:

databaseRef.child("users").childEqualsTo("username", usernameTf.text).childEqualsTo("password", passwordTf.text)

But from what I gathered, the closest thing I can do to search for this is:

databaseRef.child("users").orderByChild("username").equalsTo(usernameTf.text)

And then manually loop for the result's password if I can find any match? Is this correct?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Chen Li Yong
  • 5,459
  • 8
  • 58
  • 124
  • 1
    Firebase Database queries can only order/filter on a single property. In many cases it is possible to combine the values you want to filter on into a single (synthetic) property. For an example of this and other approaches, see my answer here: http://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase – Frank van Puffelen Jun 18 '19 at 04:22
  • @FrankvanPuffelen alright thanks! – Chen Li Yong Jun 18 '19 at 04:32

0 Answers0