Created
August 3, 2019 20:26
-
-
Save ShawonAshraf/705a426fb78e2b77d31ec20c0a3f1b14 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 data = require('./data.json'); | |
| const games = data.games; // that's what we need actually | |
| 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()); | |
| } | |
| }; | |
| // add multiple | |
| await addMultipleDocs(games, db); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment