Fixed mongo hanging script

This commit is contained in:
2022-03-14 03:38:29 +03:00
parent 946a9afeac
commit 789fb6f38d

View File

@@ -11,15 +11,16 @@ async function initDB () {
await initDB()
for (const item of items) {
console.log(`Looking at ${item.name}`)
process.stdout.write(`Looking at ${item.name}: `)
let partsPrice = 0
for (const part of item.parts) {
process.stdout.write(`${part.part} `)
partsPrice += await part.getPrice()
}
const setPrice = await item.set.getPrice()
models.ScanResult.findOneAndUpdate(
await models.ScanResult.findOneAndUpdate(
{ name: item.name },
{
fullName: item.fullName,
@@ -29,8 +30,11 @@ async function initDB () {
setPrice,
difference: setPrice - partsPrice
},
{ upsert: true },
() => {}
{ upsert: true }
)
console.log('✅')
}
await mongoose.disconnect()
})()