File tree Expand file tree Collapse file tree
Firebase/functions/src/todo Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -81,21 +81,12 @@ export const cleanupSoftDeletedTodos = onSchedule({
8181 } ,
8282 async ( ) => {
8383 try {
84- let lastDocument :
85- FirebaseFirestore . QueryDocumentSnapshot < FirebaseFirestore . DocumentData > | undefined ;
86-
8784 while ( true ) {
88- let query = admin . firestore ( )
85+ const snapshot = await admin . firestore ( )
8986 . collectionGroup ( "todoLists" )
9087 . where ( "isDeleted" , "==" , true )
91- . orderBy ( admin . firestore . FieldPath . documentId ( ) )
92- . limit ( QUERY_BATCH_SIZE ) ;
93-
94- if ( lastDocument ) {
95- query = query . startAfter ( lastDocument ) ;
96- }
97-
98- const snapshot = await query . get ( ) ;
88+ . limit ( QUERY_BATCH_SIZE )
89+ . get ( ) ;
9990 if ( snapshot . empty ) { return ; }
10091
10192 const batch = admin . firestore ( ) . batch ( ) ;
@@ -105,7 +96,6 @@ export const cleanupSoftDeletedTodos = onSchedule({
10596 await batch . commit ( ) ;
10697
10798 if ( snapshot . size < QUERY_BATCH_SIZE ) { return ; }
108- lastDocument = snapshot . docs [ snapshot . docs . length - 1 ] ;
10999 }
110100 } catch ( error ) {
111101 logger . error (
@@ -114,7 +104,6 @@ export const cleanupSoftDeletedTodos = onSchedule({
114104 {
115105 collectionGroup : "todoLists" ,
116106 filter : "isDeleted == true" ,
117- orderBy : "__name__" ,
118107 queryBatchSize : QUERY_BATCH_SIZE
119108 }
120109 ) ;
You can’t perform that action at this time.
0 commit comments