File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import 'dart:math';
66import 'package:tekartik_common_utils/common_utils_import.dart' ;
77import 'package:tekartik_firebase_firestore/firestore.dart' ;
88
9+ /// Returns -1 to abort (existing count, 0 or more is returned)
910typedef TekartikFirestoreQueryActionFunction =
1011 Future <int > Function (List <String > ids);
1112
@@ -191,6 +192,11 @@ extension TekartikFirestoreQueryExt on Query {
191192 }).toList ();
192193
193194 var processCount = await actionFunction (idsToProcess);
195+ // Return -1 to abort
196+ if (processCount < 0 ) {
197+ // Abort
198+ break ;
199+ }
194200 count += processCount;
195201 if (maxRemainingCount != null ) {
196202 maxRemainingCount -= processCount;
Original file line number Diff line number Diff line change @@ -166,6 +166,21 @@ void runUtilsQueryTest({
166166 ),
167167 4 ,
168168 );
169+ // cancel
170+ query = collRef
171+ .where ('text' , isGreaterThanOrEqualTo: '07' )
172+ .orderBy ('text' );
173+ expect (
174+ await query.queryAction (
175+ limit: 9 ,
176+ batchSize: 3 ,
177+ orderByFields: ['text' ],
178+ actionFunction: (ids) async {
179+ return - 1 ;
180+ },
181+ ),
182+ 0 ,
183+ );
169184 });
170185 });
171186}
You can’t perform that action at this time.
0 commit comments