Flutter 如何查询Firestore集合中以字符串开头的字段
如何搜索Flutter 如何查询Firestore集合中以字符串开头的字段,flutter,dart,google-cloud-firestore,Flutter,Dart,Google Cloud Firestore,如何搜索字段以某个术语开头的文档 示例:在someCollection中查找所有文档,其中someField以“foo”开头 因此,带有“foo”、“food”、“doubs”的字段将被返回,而带有“fop”、“fopp”的字段将不会被返回。这是dart对 试试这个 Stream streamQuery; streamQuery = firestore.collection('someCollection') .where('someField', isGreaterThanOrEqualT
字段
以某个术语
开头的文档
示例:在someCollection
中查找所有文档,其中someField
以“foo”开头
因此,带有“foo”、“food”、“doubs”的字段将被返回,而带有“fop”、“fopp”的字段将不会被返回。这是dart对 试试这个
Stream streamQuery;
streamQuery = firestore.collection('someCollection')
.where('someField', isGreaterThanOrEqualTo: searchKey)
.where('someField', isLessThan: searchKey +'z')
.snapshots();
这适用于大多数情况,但也有一些局限性。第一,它只提供英文字符集。其次,在“z”之后有相关字符,如
~
或{
,它们不会被返回。
Stream streamQuery;
streamQuery = firestore.collection('someCollection')
.where('someField', isGreaterThanOrEqualTo: searchKey)
.where('someField', isLessThan: searchKey +'z')
.snapshots();