【发布时间】:2017-12-20 18:00:48
【问题描述】:
我正在使用 Python 2.7 和 Pyrebase(作为与我的 Firebase 数据库通信的包)。
我试图在我的数据库中获取新推送对象的key()。我用 node.js 做了很多次,但我需要一些帮助才能用 Python 2.7 做这件事
这是我的 API:
@APP.route('/api/product', methods = ['POST'])
def products():
product_details = {
"title": request.form['title'],
"description": request.form['description']
}
new_product = DB.push("product").push(product_details)
print new_product.get().key()
return json.dumps(apiResponse.success(product_details))
对象将被插入到数据库中,但我不知道如何获取它的密钥。 在 node.js 中,我会使用一个 Promise,插入后,我会得到密钥。
P.S:我不能使用.ref(),因为我使用Pyrebase 包
【问题讨论】:
标签: python python-2.7 firebase-realtime-database callback key