Skip to content

Instantly share code, notes, and snippets.

@julienreszka
Created March 8, 2018 18:20
Show Gist options
  • Save julienreszka/9745bcf5c3afca7f828f16eb1d00c88e to your computer and use it in GitHub Desktop.
Save julienreszka/9745bcf5c3afca7f828f16eb1d00c88e to your computer and use it in GitHub Desktop.
// 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