Skip to content

Instantly share code, notes, and snippets.

@harazdovskiy
Last active October 16, 2022 18:52
Show Gist options
  • Save harazdovskiy/6bde5b695eca22962025e9154e7dc84a to your computer and use it in GitHub Desktop.
Save harazdovskiy/6bde5b695eca22962025e9154e7dc84a to your computer and use it in GitHub Desktop.
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