Prefer update documents instead of inserting

This commit is contained in:
2022-03-13 14:34:57 +03:00
parent ff2cc92b5f
commit 9e216f821f

View File

@@ -20,12 +20,12 @@ async function initDB () {
const setPrice = await item.set.getPrice() const setPrice = await item.set.getPrice()
if (partsPrice < setPrice) { if (partsPrice < setPrice) {
const scanResult = new models.ScanResult({ models.ScanResult.findOneAndUpdate(
name: item.name, { name: item.name },
partsPrice, { partsPrice, setPrice },
setPrice { upsert: true },
}) () => {}
scanResult.save() )
} }
} }
})() })()