let MongoClient = require('mongodb').MongoClient;
let url = "mongodb://localhost:27017/mydb";
MongoClient.connect(url, function(err, db) {
if (err) throw err;
//Exclude "address" field in the result:
db.collection("customers").find({}, { projection: { name: 1, address: 0 } }).toArray(function(err, result) {
if (err) throw err;
console.log(result);
db.close();
});
});
C:\Users\Your Name\node_modules\mongodb\lib\utils.js98 process.nextTick(function() { throw err; }); ^ MongoError: Projection cannot have a mix of inclusion and exclusion. ...