Skip to content Skip to sidebar Skip to footer

Firebase Matching Substring

I have the JSON structure above I want to get the list of vehicles where their ids ends with '123' I had tried to use Query.endAt() method but i'm not sure if i'm using it right o

Solution 1:

Firebase Database queries can only perform prefix matches, so strings starting with a specific string or starting with a range of string. It is not possible to query for strings ending with a specific value, nor those ending with a range of values.

If you really want to do this within Firebase, consider also storing the reversed strings in the database:

"321_1_0""321_3_0""654_52_0"

Then you can query for strings starting with 321 with

vehiclesQuery = db.getReference("vehicles").orderByKey().startAt("321").endAt("321\uf8ff");

Post a Comment for "Firebase Matching Substring"