I need to make a query for my database in Realtime Firebase
.
It is my database structure:
View
json:
{
"Recepts" : [ {
"Ingridients" : [ "Carrot", "Sugar" ],
"Name" : "Carrot Salad"
}, {
"Ingridients" : [ "Orange", "Milk" ],
"Name" : "Orange Milk"
} ]
}
How can I do a query, I make code like this:
rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference resultRef = rootRef.child("Recepts");
Query resultQuery = resultRef.orderByChild("Ingridients");
But I can not add ValueEventListener
for Query
object.
What do I need to do?
upd How can I structure my database in Firebase for search for recipes? Each recipe have some ingridients. I need to search for recipes. If the query contains several matching ingredients, Ineed to output a recipe containing a matching value