【发布时间】:2018-06-17 21:22:35
【问题描述】:
我正在关注 Google 提供的将 Stipe 与 RTDB 结合使用的教程 (https://angularfirebase.com/lessons/collect-payments-with-angular-stripe-checkout-and-firebase/),并尝试调整该示例以与 Firestore 一起使用。
本教程进行以下调用以将数据添加到 RTDB:
const payment = { token, amount }
return this.db.list(`/payments/${this.userId}`).push(payment)
我对如何在 Firestore 中执行此操作的最佳猜测是:
const payment = {token, 'price':this.props.price}
var db = firebase.firestore()
db.collection('payments').doc(this.props.uid).collection('test').add(payment)
请注意,我有“测试”集合,因为 Firestore 要求您在文档和集合之间交替。这是在 Firestore 中构建数据的正确方法吗?
【问题讨论】:
标签: firebase stripe-payments google-cloud-functions google-cloud-firestore