Created
August 9, 2019 21:18
-
-
Save pgebheim/f400babc45ad27e6efe4d1fc8fb8e856 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async setHighestSyncBlock(dbName: string, blockNumber: number, syncing: boolean, rollback = false): Promise<PouchDB.UpsertResponse> { | |
// NOTE: dbName, in this case, is actually the id of the record in the SyncStatus db. | |
return this.db.upsert(dbName, (document: SyncDocument) => { | |
// make sure the truly highest block is always being used | |
document.blockNumber = rollback ? blockNumber : Math.max(blockNumber, document.blockNumber); | |
document.syncing = syncing; | |
// db.upsert sets _rev and _id so we don't have to | |
return document; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment