Merge pull request #3872 from overleaf/jpa-batched-update-work-around-mongo-bug

[scripts] work around broken .setReadPreference() on mongo cursor

GitOrigin-RevId: 127c0593f4c20e45acb15ec26b45a45d9449d9ba
This commit is contained in:
Shane Kilkelly 2021-04-01 09:21:30 +01:00 committed by Copybot
parent ae212feec4
commit 9c38d41652

View file

@ -13,11 +13,10 @@ async function getNextBatch(collection, query, maxId, projection) {
query._id = { $gt: maxId }
}
const entries = await collection
.find(query)
.find(query, { readPreference: ReadPreference.SECONDARY })
.project(projection)
.sort({ _id: 1 })
.limit(BATCH_SIZE)
.setReadPreference(ReadPreference.SECONDARY)
.toArray()
return entries
}