projection not working with db.collection.find in mongo [duplicate]

you could separate projection like this:

    parrots.find({
        age: { $gt: +process.argv[2] }
    }).project({_id:0}).toArray(function(err, docs){
        if(err) throw err;
        console.log(docs);
        database.close();
    });

i had the same issue with being unable to get projection to work, and the above method worked for me

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)