javascript - 在 Firestore 的文档中查找文件
问题描述
我有这个漂亮的小功能......请找到以下功能:
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
(如果有的话),以及状态等于试用或活动的位置。接下来,我检查它是否为空,因为如果是,则表示没有活动订阅。但我还需要检查是否根本没有订阅,所以基本上没有订阅集合(因为订阅集合仅在处理条带时创建)。我该怎么做?
解决方案
推荐阅读
- xamarin.forms - 了解 Xamarin Essentials 首选项
- jquery - Ajax POST 抛出 500(内部服务器错误)
- c++ - 在 c 结构上调用默认构造函数
- android - 创建签名 apk 时文件名必须以 .xml 结尾
- java - 在生成的 Vertx 服务代理类中使用哪种消息通信模式?
- vb.net - 为什么我打不开这个项目的设计页面
- python-3.x - spacy 将带有数字的名称标识为 PERSON 实体
- javascript - 如何为每个对象将特定键值从一个对象添加到另一个对象数组
- javascript - 如何将类添加到标签
- javascript - firebase 数据库函数返回值