Created
June 15, 2016 14:26
-
-
Save tvalletta/9e26d61b0da6957071bda61ef9114f49 to your computer and use it in GitHub Desktop.
Mongo connection using promises
This file contains 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
'use strict'; | |
const mongoClient = require('mongodb').MongoClient; | |
const url = 'mongodb://localhost:27017/test'; | |
mongoClient.connect(url) | |
.then(conn => { | |
return conn.collection('restaurants') | |
.find().limit(10).toArray() | |
.then(out => console.log(out)) | |
.then(() => conn.close()) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment