Prefer update documents instead of inserting
This commit is contained in:
@@ -20,12 +20,12 @@ async function initDB () {
|
||||
|
||||
const setPrice = await item.set.getPrice()
|
||||
if (partsPrice < setPrice) {
|
||||
const scanResult = new models.ScanResult({
|
||||
name: item.name,
|
||||
partsPrice,
|
||||
setPrice
|
||||
})
|
||||
scanResult.save()
|
||||
models.ScanResult.findOneAndUpdate(
|
||||
{ name: item.name },
|
||||
{ partsPrice, setPrice },
|
||||
{ upsert: true },
|
||||
() => {}
|
||||
)
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
||||
Reference in New Issue
Block a user