Merge pull request #3306 from overleaf/jpa-script-validate-data-of-model

[scripts] validate-data-of-model: add the new script

GitOrigin-RevId: c432598a1efee58e95f3751ac0f63113ec837344
This commit is contained in:
Jakob Ackermann
2020-10-22 02:04:48 +00:00
committed by Copybot
parent 21070a01a8
commit 224c5a0f23
2 changed files with 50 additions and 1 deletions
@@ -8,6 +8,7 @@ if (process.env.BATCH_LAST_ID) {
}
async function getNextBatch(collection, query, maxId, projection) {
maxId = maxId || BATCH_LAST_ID
if (maxId) {
query['_id'] = { $gt: maxId }
}
@@ -35,7 +36,7 @@ async function batchedUpdate(collectionName, query, update, projection) {
projection = projection || { _id: 1 }
let nextBatch
let updated = 0
let maxId = BATCH_LAST_ID
let maxId
while (
(nextBatch = await getNextBatch(collection, query, maxId, projection))
.length
@@ -66,6 +67,7 @@ function batchedUpdateWithResultHandling(collection, query, update) {
}
module.exports = {
getNextBatch,
batchedUpdate,
batchedUpdateWithResultHandling
}