Flutter 我怎样才能在firestore循环查询中进行颤振
我想做一个查询,如果它符合一个条件,我想把这个查询作为下一个查询。有人知道我怎么做吗 我的目标是在客户机上执行此操作,因为没有非数组查询Flutter 我怎样才能在firestore循环查询中进行颤振,flutter,google-cloud-firestore,Flutter,Google Cloud Firestore,我想做一个查询,如果它符合一个条件,我想把这个查询作为下一个查询。有人知道我怎么做吗 我的目标是在客户机上执行此操作,因为没有非数组查询 Query _query(List<dynamic> startAfter) { CollectionReference col = _firestore.collection("users"); Query xx= col.where('xx', whereIn: _xx); Query yy = xx.where('yy
Query _query(List<dynamic> startAfter) {
CollectionReference col = _firestore.collection("users");
Query xx= col.where('xx', whereIn: _xx);
Query yy = xx.where('yy', arrayContains: _yy);
Query zz = yy.orderBy('zz');
Query start;
if (startAfter.length > 0) {
start = zz.startAfter(startAfter);
} else {
start = zz;
}
Query limit = start.limit(1);
return limit;
}
Query\u查询(列表开始后){
CollectionReference col=_firestore.collection(“用户”);
查询xx=col.where('xx',其中:_xx);
查询yy=xx,其中('yy',数组内容:_-yy);
查询zz=yy.orderBy('zz');
查询启动;
如果(startAfter.length>0){
开始=zz.startAfter(startAfter);
}否则{
开始=zz;
}
查询限额=起始限额(1);
退货限额;
}
我是这样想的,但我想我做不好
_query([]).getDocuments().then((onValue) {
if (onValue.documents.length > 0) {
if (_all.contains(onValue.documents.first.documentID)) {
List<DocumentSnapshot> doc = onValue.documents;
String id = doc.first.documentID;
do {
_query(doc).getDocuments().then((onValue) {
doc = onValue.documents;
id = doc.first.documentID;
});
}
while(_all.contains(id) == false);
if(doc.length > 0) {
debugPrint('found');
} else {
debugPrint('could not find');
}
} else {
debugPrint('found');
}
} else {
debugPrint('could not find');
}
\u查询([]).getDocuments().then((onValue){
如果(onValue.documents.length>0){
if(_all.contains(onValue.documents.first.documentID)){
列表单据=onValue.documents;
字符串id=doc.first.documentID;
做{
_查询(doc).getDocuments().then((onValue){
doc=onValue.documents;
id=doc.first.documentID;
});
}
while(_all.contains(id)=false);
如果(文档长度>0){
debugPrint('found');
}否则{
debugPrint('找不到');
}
}否则{
debugPrint('found');
}
}否则{
debugPrint('找不到');
}
你可以用wait这样做
Future<QuerySnapshot> _query([DocumentSnapshot startAfter]) {
CollectionReference col = _firestore.collection("users");
Query xx= col.where('xx', whereIn: _xx);
Query yy = xx.where('yy', arrayContains: _yy);
Query zz = yy.orderBy('zz');
Query start;
if (startAfter != null) {
start = order.startAfterDocument(startAfter);
} else {
start = order;
}
Query limit = start.limit(1);
return limit.getDocuments();
}
Future\u查询([DocumentSnapshot startAfter]){
CollectionReference col=_firestore.collection(“用户”);
查询xx=col.where('xx',其中:_xx);
查询yy=xx,其中('yy',数组内容:_-yy);
查询zz=yy.orderBy('zz');
查询启动;
if(startAfter!=null){
开始=订单.startAfter文档(startAfter);
}否则{
开始=订单;
}
查询限额=起始限额(1);
返回限制。getDocuments();
}
之后:
QuerySnapshot snap = await _query();
if (snap.documents.length > 0) {
if (_all.contains(onValue.documents.first.documentID)) {
List<DocumentSnapshot> doc = snap.documents;
while (doc.length > 0 && _all.contains(doc.first.documentID) == false) {
QuerySnapshot snap2 = await _query(doc.first);
doc = snap2.documents;
}
if (doc.length > 0) {
debugPrint('found');
} else {
debugPrint('could not find');
}
} else {
debugPrint('found');
}
} else {
debugPrint('could not find');
}
QuerySnapshot snap=wait_query();
如果(snap.documents.length>0){
if(_all.contains(onValue.documents.first.documentID)){
列表单据=snap.documents;
而(doc.length>0&&u all.contains(doc.first.documentID)==false){
QuerySnapshot snap2=等待查询(doc.first);
doc=snap2.documents;
}
如果(文档长度>0){
debugPrint('found');
}否则{
debugPrint('找不到');
}
}否则{
debugPrint('found');
}
}否则{
debugPrint('找不到');
}