MongoDB Certified DBA Associate (C100DBA) — Question 3
Which two commands project the “product” and “_id” fields? (Choose two.)
Answer options
- A. db.coll.find({}, {“product”: 1})
- B. db.coll.find({}, {“product”: 1, “_id”: 1})
- C. db.coll.find({}).project({“product”: 1, “_id”: 1})
- D. db.coll.find({}).project({“product”: 1})
Correct answer: B, C
Explanation
Option B is correct because it specifies both 'product' and '_id' fields for projection. Option C is also correct since it uses the project method to include the same fields. Options A and D are incorrect as they only project the 'product' field, thereby omitting the '_id' field.