Fix for loosing events when force updating vehicle
This commit is contained in:
parent
d8fc7d81b7
commit
9d05646162
@ -59,6 +59,12 @@ router.post('/check', async (req, res) => {
|
||||
vehicle.ownershipPeriods = vin01.value.ownershipPeriods;
|
||||
}
|
||||
}
|
||||
|
||||
// In case of force update of existing vehicle, transfer all events to the new DB record
|
||||
if (vehicles.length > 0) {
|
||||
vehicle.events = vehicles[0].events;
|
||||
}
|
||||
|
||||
await collection.replaceOne({ number }, vehicle, { upsert: true });
|
||||
res.status(201).send({ success: true, data: vehicle });
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user