1.

Which of the following query selects documents in the records collection that match the condition { “user_id”: { $lt: 42 } }?(a) db.records.findOne( { “user_id”: { $lt: 42 } }, { “history”: 0 } )(b) db.records.find( { “user_id”: { $lt: 42 } }, { “history”: 0 } )(c) db.records.findOne( { “user_id”: { $lt: 42 } }, { “history”: 1 } )(d) db.records.select( { “user_id”: { $lt: 42 } }, { “history”: 0 } )

Answer» Right answer is (b) db.records.find( { “user_id”: { $lt: 42 } }, { “history”: 0 } )

To elaborate: Query uses the projection { “history”: 0 } to exclude the history field from the documents in the result set.


Discussion

No Comment Found