I have something like this:
"records" : {
"-KOHf6O3V35jqR4mENo1" : {
"name" : "Foo",
"type" : "One"
},
"-KOHf6O3V35jqR4mENo2" : {
"name" : "Bar",
"type" : "Two"
},
"-KOHf6O3V35jqR4mENo3" : {
"name" : "Qux",
"type" : "One"
},
"-KOHf6O3V35jqR4mENo4" : {
"name" : "Baz",
"type" : "One"
},
}
I want to get the first two records with type == "One" ordered by name.
I can get the first two records ordered by name using:
var ref = firebase.database().ref("records");
ref.orderByChild("name").limitToFirst(2).on("child_added", function(snapshot) {
console.log(snapshot.val());
});
I also can get all the records with type == "One":
var ref = firebase.database().ref("records");
ref.orderByChild("type").equalTo("One").on("child_added", function(snapshot) {
console.log(snapshot.val());
});
Is there any way to order the records by a property and filter them by another?
(The real record list would have thousands of records)