Skip to content

Instantly share code, notes, and snippets.

@ShawonAshraf
Created August 3, 2019 20:15
Show Gist options
  • Select an option

  • Save ShawonAshraf/30c9b1170e1fdbca3b7541ca90303908 to your computer and use it in GitHub Desktop.

Select an option

Save ShawonAshraf/30c9b1170e1fdbca3b7541ca90303908 to your computer and use it in GitHub Desktop.
Code for mongodb-nodejs-medium article
const docToUpdate = { name: 'Halo MCC' };
const updateTerm = { $set: { name: 'Halo Master Chief Collection' } };
console.log('Before update :');
let haloMcc = await db.collection('games').findOne(docToUpdate);
console.log(haloMcc);
await updateDoc(db, docToUpdate, updateTerm);
// check
haloMcc = await db.collection('games').findOne({
name: 'Halo Master Chief Collection'
});
console.log('After update :')
console.log(haloMcc);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment