for (const dbName of dbs) { const d = db.getSiblingDB(dbName); const cols = d.getCollectionNames(); for (const colName of cols) { const c = d.getCollection(colName); const fields = ["theme", "theme_id", "selected_theme", "embed_theme", "widget_theme.id", "widget_theme.theme", "settings.theme", "settings.embed_theme"]; for (const f of fields) { const q = {};q[f] = { $in: legacy }; const u = { $set: {} };u.$set[f] = "coverflow"; try { const res = c.updateMany(q, u); if (res.modifiedCount) print(dbName + "." + colName + " " + f + " -> " + res.modifiedCount); } catch (e) {} } } }