Reputation: 107
Im using node with mongo, and I want for the mongo get call to stop returning some values, such as _id and uid. Everything that ive read says that this call should work, but when I print the json value on my UI, it still has those values.
app.get('/users', async function(req, res){
console.log("Getting User Info!");
await client.connect();
const db = client.db('database');
var uidparam = req.header("uid");
db.collection("users").findOne({"uid": uidparam}, { _id: 0, uid: 0, }, function(err, result) {
if (err) throw err;
res.send(result);
});
});
Ive also tried
{ "_id": false, "uid": false, }
and
{ _id: false, uid: false, }
and
{ '_id': 0, 'uid': 0, }
Upvotes: 0
Views: 33
Reputation: 4034
Following along with this example for Node, it looks like you need to specify a projection
field for the options document. It would look like this:
{
projection: {
_id: 0,
uid: 0
}
}
Upvotes: 1