Created
March 8, 2018 18:20
-
-
Save julienreszka/9745bcf5c3afca7f828f16eb1d00c88e to your computer and use it in GitHub Desktop.
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
// demo_mongodb_find_fields.js | |
var MongoClient = require('mongodb').MongoClient; | |
var url = "mongodb://localhost:27017/"; | |
MongoClient.connect(url, (err, db) => { | |
if (err) throw err; | |
var dbo = db.db("mydb"); | |
dbo | |
.collection("customers") | |
.find({},{projection:{_id:0, name:1, address:1}}) | |
.toArray((err, result) => { | |
if (err) throw err; | |
console.log(result); | |
db.close(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment