Pyrebase-如何从Firebase实时数据库中获取最新记录

问题描述 投票:0回答:1

我正在使用Pyrebase从实时数据库接收数据。实际上,我可以直接接收数据,但是我只需要最新记录。This is the Realtime Database

python firebase firebase-realtime-database pyrebase
1个回答
0
投票

假设最大的键(这里为4)是最近的记录,这是如何使用pyrebase直接检索它:

pyrebase

[firebase = pyrebase.initialize_app(config) db = firebase.database() last_record = db.child('input').order_by_key().limit_to_last(1).get().val() print(last_record) # should print OrderedDict([('4', {'input1': ..., 'input2': ..., 'input3': ...})]) order_by_key orders in ascending order by default确保您只检索一条记录,这是查询中的最后一条。

[order_by_key,它的一个分支,limit_to_last(1)已修复,请确保使用它:]]

However there is a bug for calling order_by in the pyrebase library
© www.soinside.com 2019 - 2024. All rights reserved.