File tree Expand file tree Collapse file tree 1 file changed +45
-2
lines changed
modules/module-mongodb-storage/src/storage/implementation Expand file tree Collapse file tree 1 file changed +45
-2
lines changed Original file line number Diff line number Diff line change 99} from '@powersync/lib-services-framework' ;
1010import {
1111 BroadcastIterable ,
12- CHECKPOINT_INVALIDATE_ALL ,
1312 CheckpointChanges ,
1413 GetCheckpointChangesOptions ,
1514 InternalOpId ,
@@ -870,6 +869,50 @@ export class MongoSyncBucketStorage
870869 }
871870
872871 async getCheckpointChanges ( options : GetCheckpointChangesOptions ) : Promise < CheckpointChanges > {
873- return CHECKPOINT_INVALIDATE_ALL ;
872+ const dataBuckets = await this . db . bucket_data
873+ . find (
874+ {
875+ '_id.g' : this . group_id ,
876+ '_id.o' : { $gt : BigInt ( options . lastCheckpoint ) , $lte : BigInt ( options . nextCheckpoint ) }
877+ } ,
878+ {
879+ projection : {
880+ '_id.b' : 1
881+ } ,
882+ limit : 1001 ,
883+ batchSize : 1001 ,
884+ singleBatch : true
885+ }
886+ )
887+ . toArray ( ) ;
888+ const invalidateDataBuckets = dataBuckets . length > 1000 ;
889+
890+ const parameterUpdates = await this . db . bucket_parameters
891+ . find (
892+ {
893+ _id : { $gt : BigInt ( options . lastCheckpoint ) , $lt : BigInt ( options . nextCheckpoint ) } ,
894+ 'key.g' : this . group_id
895+ } ,
896+ {
897+ projection : {
898+ lookup : 1
899+ } ,
900+ limit : 1001 ,
901+ batchSize : 1001 ,
902+ singleBatch : true
903+ }
904+ )
905+ . toArray ( ) ;
906+ const invalidateParameterUpdates = parameterUpdates . length > 1000 ;
907+
908+ return {
909+ invalidateDataBuckets,
910+ updatedDataBuckets : invalidateDataBuckets ? [ ] : dataBuckets . map ( ( b ) => b . _id . b ) ,
911+
912+ invalidateParameterBuckets : invalidateParameterUpdates ,
913+ updatedParameterBucketDefinitions : invalidateParameterUpdates
914+ ? [ ]
915+ : [ ...new Set < string > ( parameterUpdates . map ( ( p ) => getLookupBucketDefinitionName ( p . lookup ) ) ) ]
916+ } ;
874917 }
875918}
You can’t perform that action at this time.
0 commit comments