Firebase queryEqualToValue with childKey

I am trying to query data in a Firebase database using:

queryEqual(toValue: Any?, childKey: String?)

My database structure:

Schools {
    testUID1 {
        schoolNameLC: test school 1
    }
}

My request:

databaseReference.child("Schools").queryEqual(toValue: "test school 1", childKey: "schoolNameLC").observe(.value) { (snap) in
        print(snap)
    }

This query prints null, and I cannot get it to work. Due to how my application is configured, I do not know that the key schoolNameLCmatters testSchool1under the parent key testUID1. All I want to do is search through Schoolsmy database and return something with a schoolNameLCvalue test school 1.

+3
source share
1 answer

queryEqualToValue:childKey: ( queryStartingAtValue:childKey: queryEndingAtValue:childKey:), , API Firebase.

, queryOrderedByChild().queryEqualToValue(). @ElCaptainV2.0 :

databaseReference.child("Schools")
    .queryOrderedByChild("scho‌​olNameLC")
    .queryEqua‌​lToValue("test school 1")

childKey:, test school 1. , / .

+8

Source: https://habr.com/ru/post/1677706/


All Articles