firebase - 如何在 collection.document.collection.document() 颤振飞镖中检查 firebase 中的特定值
问题描述
我想检查 collection.document.collection.document() 中的某个 id 是否在 firebase flutter dart 中可用,如果是这样,我删除 id 否则我在数据库中添加该 id。
所以我的问题是访问 id 值,我尝试了 .contains 方法,但即使该值存在,它也总是返回 false。我该如何解决这个问题
这是我的防火设计
Firestore.instance .collection('postt') .document(postsId) .collection('type') .document();
解决方案
我不知道您的 Firestore 设计是什么样的,但根据您的描述,这个示例应该可以工作。
DocumentSnapshot doc = await FirebaseFirestore.instance.collection('posst')
.doc('postsId')
.collection('type')
.where('id',isEqualTo: 'your id')
.get();
if(doc.exists){
// todo
}else{
// todo
}
推荐阅读
- java - 如何将视图添加到主活动中的多个布局
- javascript - JS 在可变元素集中旋转可变图像堆栈
- python - Web Scraping 'NoneType' 对象不可下标
- javascript - 在反应组件内部调用暂停函数但没有任何反应
- applescript - 在任何应用程序中通过 Automator 在 Applescript 中发送击键
- python - 为什么不能在条件语句的代码中排除 LCM 变量?
- reactjs - 盖茨比网站的 Netlify“build.command”失败
- python - 图像地图热点中的条件语句?
- javascript - jquery没有按名称捕获输入选择器
- javascript - setTimeout 立即执行,而不是函数调用中传递的时间