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 ?
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 })