0

My Firebase structure is as below. I'm using python to use firebase, and also I use Pyrebase.

I want to get a key, which looks like '288xxxxxx' from the value(busStopName). Can I get the answer in Pyrebase?

Thank you in advance...

enter image description here

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Jung Jaehoon
  • 101
  • 1
  • 12

1 Answers1

1

The following should work, based on the documentation

searched_bus = db.child("asanbus").order_by_child("busStopName").equal_to("XYZ").get()
for bus in searched_bus.each():
    print(bus.key()) 

Assumption: there is only one record corresponding to busStopname = "XYZ". If not the case, you may do:

searched_bus = db.child("asanbus").order_by_child("busStopName").equal_to("XYZ").limit_to_first(1).get()
Renaud Tarnec
  • 79,263
  • 10
  • 95
  • 121