Easy javascript

Find with projection

Problem

Return only name and salary fields.

Hints
  • Second argument { name: 1, salary: 1, _id: 0 }

Your practice code

Ready — edit the code above and click Run.

Solution

db.employees.find({}, { name: 1, salary: 1, _id: 0 });

Try solving on your own first, then reveal the official answer.

Explanation

Projection 1 includes field, _id: 0 excludes default _id.

Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details