Guest User

Untitled

a guest
May 27th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. var MongoClient = require('mongodb').MongoClient;
  2.  
  3. const accountGetter = (accountCollection) => {
  4. return MongoClient.connect('mongodb://localhost:27017', (err, client)=>{
  5. if(err) return console.log(err)
  6. const db = client.db('papa')
  7. const collection = db.collection(accountCollection)
  8.  
  9. collection.find({}).toArray((err, docs)=>{
  10. if(err)return console.log(err);
  11. console.log(docs)
  12. return docs
  13. })
  14. })
  15. }
  16.  
  17. module.exports = accountGetter;
Add Comment
Please, Sign In to add comment