mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
03f45c02c3
[web] add time based window queries to batchedUpdate GitOrigin-RevId: e56c01b888cd9749f39d42b77de09bc3fe2d0ec1
23 lines
555 B
JavaScript
23 lines
555 B
JavaScript
const { batchedUpdateWithResultHandling } = require('./helpers/batchedUpdate')
|
|
|
|
const MODEL_NAME = process.argv.pop()
|
|
const Model = require(`../app/src/models/${MODEL_NAME}`)[MODEL_NAME]
|
|
|
|
function processBatch(batch) {
|
|
for (const doc of batch) {
|
|
const error = new Model(doc).validateSync()
|
|
if (error) {
|
|
const { errors } = error
|
|
console.log(JSON.stringify({ _id: doc._id, errors }))
|
|
}
|
|
}
|
|
}
|
|
|
|
batchedUpdateWithResultHandling(
|
|
Model.collection.name,
|
|
{},
|
|
async (_, nextBatch) => {
|
|
await processBatch(nextBatch)
|
|
},
|
|
{}
|
|
)
|