migration to fix null values instead of array of events
This commit is contained in:
parent
bad9a810de
commit
b7902a569e
15
migration.js
15
migration.js
@ -38,8 +38,21 @@ async function addDebugInfoStatus() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function fixNullEvents() {
|
||||||
|
let client = await MongoClient.connect(process.env.MONGO_CONNECTION_STRING, { useUnifiedTopology: true });
|
||||||
|
let db = client.db('autocatdev');
|
||||||
|
let collection = db.collection('vehicles');
|
||||||
|
let vehicles = await collection.find().toArray();
|
||||||
|
for(let vehicle of vehicles) {
|
||||||
|
if(vehicle.events == null) {
|
||||||
|
await collection.updateOne({ number: vehicle.number }, { $set: { events: [] } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
//await addUpdatedDate();
|
//await addUpdatedDate();
|
||||||
await addDebugInfoStatus();
|
//await addDebugInfoStatus();
|
||||||
|
await fixNullEvents();
|
||||||
console.log('====== Done ======');
|
console.log('====== Done ======');
|
||||||
})();
|
})();
|
||||||
Loading…
Reference in New Issue
Block a user