Skip to content

Instantly share code, notes, and snippets.

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

  • Save ShawonAshraf/2c30e61d52c02497ea0ab418c138b95c to your computer and use it in GitHub Desktop.

Select an option

Save ShawonAshraf/2c30e61d52c02497ea0ab418c138b95c to your computer and use it in GitHub Desktop.
Code for mongodb-nodejs-medium article
const addOneDocument = async(doc, db) => {
try {
// const db = client.db();
await db.collection('games').insertOne(doc);
console.log('Document has been updated! ...');
} catch (e) {
console.log(e.toString());
}
};
const addMultipleDocs = async(docs, db) => {
try {
// const db = client.db();
await db.collection('games').insertMany(docs);
console.log('Multiple Docs Added!');
} catch (e) {
console.log(e.toString());
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment