db.users.find({}) returns all the users with all the field.
How to write a request that would return only the 'email' field for all user ?
Please take a look at the documentation. You will notice that find
has an optional second parameter called "projection". This parameter is used to state which fields you want. To get only the field named "email", use this projection:
db.users.find({}, { _id: 0, email: 1 })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With