[英]Firebase: How to get a list of all child nodes?
如何獲取實時數據庫中的子節點列表?
這是我的數據庫的樣子:
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)
所以我試圖得到一個看起來像[user1, user2, user3, user4]
的列表。
把它放在一個像這樣的變量中:
nodes = database.child('nameOfChild').get().val()
如果你只想要節點名稱,你可以這樣做:
nodes = database.child('nameOfChild').get().val().keys()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.