Last active
October 16, 2022 18:52
-
-
Save harazdovskiy/6bde5b695eca22962025e9154e7dc84a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const dotenv = require('dotenv'); | |
dotenv.config() | |
const {MongoClient, ServerApiVersion} = require('mongodb'); | |
const DB_NAME = 'performance63m'; | |
const COLLECTION_NAME = '63mil-collection'; | |
(async () => { | |
try { | |
const col = await getCollection(); | |
console.time('Updating 1,3mil data'); | |
const res = await col.updateMany({language: 'polish'}, {$unset: {isPolish: true}}); | |
console.timeEnd('Updating 1,3mil data'); | |
console.log(res) | |
process.exit(); | |
} catch (e) { | |
console.error(e); | |
client.close() | |
} | |
})(); | |
async function getCollection() { | |
const client = new MongoClient(process.env.MONGO_CLUSTER_M30, { | |
useNewUrlParser: true, | |
useUnifiedTopology: true, | |
serverApi: ServerApiVersion.v1 | |
}); | |
await client.connect(); | |
console.log('Connected successfully to server'); | |
const db = client.db(DB_NAME); | |
return db.collection(COLLECTION_NAME) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment