My database:
Based on this, how can I get a recipe, searching by a ingredient description using rest service in firebase?
I've tried it: /recipe.json?orderBy="ingredients/description"&equalTo="teste"
but I had no success.
My database:
Based on this, how can I get a recipe, searching by a ingredient description using rest service in firebase?
I've tried it: /recipe.json?orderBy="ingredients/description"&equalTo="teste"
but I had no success.
Firebase Database queries can search on values at a known path under the children of the location you query. Your values are instead at a dynamic path: the teste
ingredient can be ingredient/0
, ingredient/1
, etc. That is a query that is not possible with the Firebase database.
With your current data a simple change to allow the query is to use the ingredient description as the key:
"ingredients": {
"teste": 1,
"teste2": 3
}
Then you can query with something like:
/recipe.json?orderBy="ingredients/teste"&startAt=0
In general this type of nesting of collections is discouraged with the Firebase Realtime Database. For more information, see: