Flutter 扑动火基飞片阵列容器
我有一个动态填充的字符串列表(MAS5项)。现在我想根据这些项目从firsestore筛选文档,所以我写了以下内容:Flutter 扑动火基飞片阵列容器,flutter,google-cloud-firestore,Flutter,Google Cloud Firestore,我有一个动态填充的字符串列表(MAS5项)。现在我想根据这些项目从firsestore筛选文档,所以我写了以下内容: List<String> lst= new List(); lst.add('A'); lst.add('B'); lst.add('C'); Query collectionRef = Firestore.instance .collection("files") .document(Userpref.la
List<String> lst= new List();
lst.add('A');
lst.add('B');
lst.add('C');
Query collectionRef = Firestore.instance
.collection("files")
.document(Userpref.language)
.collection("files")
.where("describeFear", arrayContainsAny: [
lst
]);
List lst=new List();
第1条添加(“A”);
第1条添加(‘B’);
第1条添加('C');
Query collectionRef=Firestore.instance
.collection(“文件”)
.document(Userpref.language)
.collection(“文件”)
.其中(“描述”),ArrayContainesAny:[
lst
]);
在[]内,如果我将列表名称放入,则它将不起作用。
此外,如果我将列表中的所有项都放在一个变量中,并将其传递给[],则它将不起作用
它唯一有效的时候是当我把像这样的值'A','B','C'。这是可行的,但我需要传递数组,因为它是动态的。
有人能帮忙吗?您正在将
列表
对象放入一个数组中,因此您最终会查找具有一个数组的文档,其中单个项是[“A”、“B”、“C”]
你想要的是:
List<String> lst= new List();
lst.add('A');
lst.add('B');
lst.add('C');
Query collectionRef = Firestore.instance
.collection("files")
.document(Userpref.language)
.collection("files")
.where("describeFear", arrayContainsAny: lst);
List lst=new List();
第1条添加(“A”);
第1条添加(‘B’);
第1条添加('C');
Query collectionRef=Firestore.instance
.collection(“文件”)
.document(Userpref.language)
.collection(“文件”)
.其中(“描述”,阵列内容:lst);
您将列表
对象放入一个数组中,因此您最终会查找具有数组的文档,其中单个项为[“A”、“B”、“C”]
你想要的是:
List<String> lst= new List();
lst.add('A');
lst.add('B');
lst.add('C');
Query collectionRef = Firestore.instance
.collection("files")
.document(Userpref.language)
.collection("files")
.where("describeFear", arrayContainsAny: lst);
List lst=new List();
第1条添加(“A”);
第1条添加(‘B’);
第1条添加('C');
Query collectionRef=Firestore.instance
.collection(“文件”)
.document(Userpref.language)
.collection(“文件”)
.其中(“描述”,阵列内容:lst);
最新版本的:
Flatter+cloud\u firestore:^0.14.0+2
我面临一个类似的问题,查询返回的是空数据:
FutureBuilder(
future: _sessionsLogCollection
.where('companyId', isEqualTo: sPData.companyId)
.where('locationId', arrayContainsAny: [
'29L73oSzdQrzLUow3Mg9',
'bugdWVC6RRtHoemuxNWE',
])
// .where('locationId', isEqualTo: 'bugdWVC6RRtHoemuxNWE')
.orderBy('openDateTime', descending: true)
.get(),
我已经创建了索引,所以这不是问题所在
单独使用.where('locationId',isEqualTo:'bugdvc6rrthoemuxnwe')时,查询返回正确的数据。但是对于.where('locationId',arrayContainsAny:['29L73oSzdQrzLUow3Mg9','bugdWVC6RRtHoemuxNWE'])单独使用,它不会给出任何错误,只会返回空数据集:sessionsSnapShot.data.documents.length:0
编辑:当locationId本身是数组时,arrayContainsAny:将起作用。但是,如果locationId是一个字符串字段,则应使用,其中:
Flatter+cloud\u firestore:^0.14.0+2
我面临一个类似的问题,查询返回的是空数据:
FutureBuilder(
future: _sessionsLogCollection
.where('companyId', isEqualTo: sPData.companyId)
.where('locationId', arrayContainsAny: [
'29L73oSzdQrzLUow3Mg9',
'bugdWVC6RRtHoemuxNWE',
])
// .where('locationId', isEqualTo: 'bugdWVC6RRtHoemuxNWE')
.orderBy('openDateTime', descending: true)
.get(),
我已经创建了索引,所以这不是问题所在
单独使用.where('locationId',isEqualTo:'bugdvc6rrthoemuxnwe')时,查询返回正确的数据。但是对于.where('locationId',arrayContainsAny:['29L73oSzdQrzLUow3Mg9','bugdWVC6RRtHoemuxNWE'])单独使用,它不会给出任何错误,只会返回空数据集:sessionsSnapShot.data.documents.length:0
编辑:当locationId本身是数组时,arrayContainsAny:将起作用。然而,如果locationId是一个字符串字段,那么应该使用其中:。对于这个用例,您需要使用where而不是arrayContainy
List lst=new List();
第1条添加(“A”);
第1条添加(‘B’);
第1条添加('C');
Query collectionRef=Firestore.instance
.collection(“文件”)
.document(Userpref.language)
.collection(“文件”)
.其中(“描述”),其中:[
lst
]);代码>对于此用例,您需要使用where而不是arrayContainsAny
List lst=new List();
第1条添加(“A”);
第1条添加(‘B’);
第1条添加('C');
Query collectionRef=Firestore.instance
.collection(“文件”)
.document(Userpref.language)
.collection(“文件”)
.其中(“描述”),其中:[
lst
]);
您现在显示的内容不起作用,因为您没有将任何项目传递到ArrayContainesAny
,但我认为这不是您真正需要解决的问题。您能否更新问题中的代码,以显示不起作用的准确、完整/独立的代码?您现在显示的代码将不起作用,因为您没有将任何项目传递到ArrayContainesany
,但我认为这并不是您真正需要解决的问题。您能否更新问题中的代码,以显示不起作用的准确、完整/独立的代码?