Reputation: 7
How am I able to get a list of the child nodes in my realtime database?
This is what my database looks like:
firebase = pyrebase.initialize_app(config)
database = firebase.database()
author = ctx.message.author
now = datetime.now()
data = {
'Submit by': f'{author.name}#{author.discriminator}',
'Date': now.strftime("%d/%m/%Y %H:%M:%S CET")
}
database.child(str(username)).set(data)
So I'm trying to get a list that would look like [user1, user2, user3, user4]
.
Upvotes: 0
Views: 904
Reputation: 71
put it in a varaible like this:
nodes = database.child('nameOfChild').get().val()
if you want just the nodes names you can do this:
nodes = database.child('nameOfChild').get().val().keys()
Upvotes: 1