2023-03-21 05:09:06 -04:00
|
|
|
const { batchedUpdateWithResultHandling } = require('./helpers/batchedUpdate')
|
2020-10-21 05:48:30 -04:00
|
|
|
|
|
|
|
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 }))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-21 05:09:06 -04:00
|
|
|
batchedUpdateWithResultHandling(
|
|
|
|
Model.collection.name,
|
|
|
|
{},
|
|
|
|
async (_, nextBatch) => {
|
|
|
|
await processBatch(nextBatch)
|
|
|
|
},
|
|
|
|
{}
|
|
|
|
)
|