Fixing error in migration
This commit is contained in:
parent
3f9517c542
commit
1e0808f839
@ -12,7 +12,7 @@ async function addUpdatedDate() {
|
||||
let vehicles = await collection.find().toArray();
|
||||
for(let vehicle of vehicles) {
|
||||
let updatedDate = vehicle.addedDate;
|
||||
if(vehicle.events.length > 0) {
|
||||
if(vehicle.events && vehicle.events.length > 0) {
|
||||
let lastEvent = vehicle.events.reduce((acc, cur) => acc.date > cur.date ? acc : cur);
|
||||
updatedDate = Math.max(1000*lastEvent.date, vehicle.addedDate);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user