Fixed mongo hanging script
This commit is contained in:
@@ -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()
|
||||
})()
|
||||
|
||||
Reference in New Issue
Block a user