overleaf/services/track-changes/scripts/flush_all.js
Miguel Serrano 577a8a3ee2 Merge pull request #11791 from overleaf/msm-track-changes-flush-fix
[track-changes] add `waitForDb` to `scripts/flush_all.js`

GitOrigin-RevId: 318c0b4334bd70dddb3b5fe585e70c51d54af491
2023-02-13 10:06:35 +00:00

27 lines
603 B
JavaScript

const UpdatesManager = require('../app/js/UpdatesManager')
const { waitForDb } = require('../app/js/mongodb')
async function main() {
await waitForDb()
return new Promise((resolve, reject) => {
const limit = -1
console.log('Flushing all updates')
UpdatesManager.flushAll(limit, err => {
if (err) {
reject(err)
} else {
resolve()
}
})
})
}
main()
.then(() => {
console.log('Done flushing all updates')
process.exit(0)
})
.catch(error => {
console.error('There was an error flushing updates', { error })
process.exit(1)
})