我想查看“ chefCollection”中的任何文档中是否存在“ chefId”(屏幕快照的带圆圈的字段)。为此,我在下面的查询中编写。
Future<bool> checkChefID(String userID) async {
final chefCheck = (await Firestore.instance.collection('chef')
.document("chefId")
.collection("chef")
.where("chefID", isEqualTo: userID)
.getDocuments())
.documents;
print("Query result: " + chefCheck.toString());
chefCheck.length > 0 ? return true : return false;
}
在上面的函数中,此(rhnKjYg2yMhf5IVjI0zvTi7Mjpn2)作为userID参数传递。
它确实存在于Chef集合中
这是我得到打印声明的结果
I/flutter (20455): Query result []
答案 0 :(得分:1)
更改此:
if (!document.hasFocus()) await this.waitForTabFocus();
videoEl.play();
对此:
final chefCheck = (await Firestore.instance.collection('chef')
.document("chefId")
.collection("chef")
.where("chefID", isEqualTo: userID)
.getDocuments())
.documents;
在数据库中,您有一个名为final chefCheck = (await Firestore.instance.collection('chef')
.where("chefID", isEqualTo: userID)
.getDocuments())
.documents;
的集合,并且在文档内部有一个名为chef
的字段,因此您不应该有chefID