我有这个漂亮的小功能......请找到以下功能:
firestore.collection('customers').doc(user.uid).collection('subscriptions')
.where('status', 'in', ['trialing', 'active']).get()
.then(activeSubscriptions => {
// if this is true, the user has no active subscription.
if (activeSubscriptions.empty === true) {
var activityStatus = "canceled"
createCheckoutSession(activityStatus)
} else if (activeSubscriptions.size > 1){
alert("you have more then one active subscription. please manage your subscriptions and cancel one of your subscriptions to access the application")
} else {
this.props.history.push(routes.CLIENTS)
}
});
它基本上检查集合customers,与我传入的用户 ID 匹配的文档,然后是集合subscriptions(如果有的话),以及状态等于试用或活动的位置。接下来,我检查它是否为空,因为如果是,则表示没有活动订阅。但我还需要检查是否根本没有订阅,所以基本上没有订阅集合(因为订阅集合仅在处理条带时创建)。我该怎么做?