Created
August 3, 2019 20:19
-
-
Save ShawonAshraf/2c30e61d52c02497ea0ab418c138b95c to your computer and use it in GitHub Desktop.
Code for mongodb-nodejs-medium article
This file contains hidden or 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 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