首页 > 解决方案 > 检查字符串是否已存在于 cloudfirestore 字段中的字段中并颤动

问题描述

我在cloudfirestore中有一个名为IDS的集合,里面有一个名为IDs的文档,在这个文档中我有以ID1开头的字段几乎达到ID14000,用户在文本字段中输入他的id,我需要检查id是否存在在田野里谢谢。

标签: dartgoogle-cloud-firestoreflutter

解决方案


final CollectionReference dbIDS = Firestore.instance.collection('IDS');

QuerySnapshot _query = await dbIDS
    .where('ID', isEqualTo: theUserInputID)
    .getDocuments();

if (_query.documents.length > 0) {
  // the ID exists
}

推荐阅读