Querying data is one of the most crucial aspects of working with MongoDB. It involves retrieving, filtering, and projecting data stored in collections. Query operators such as $eq, $lt, $in, $and, and $not provide powerful ways to extract specific data, while projection allows fine-tuning of results by including or excluding fields. In interviews, you may be asked to solve complex query problems or optimize queries, making it essential to master these concepts.
1.) Which MongoDB operator matches documents where a field’s value equals the specified value?
2.) Which of the following operators is used to match values less than a specified value?
3.) What does the $in operator do in MongoDB?
4.) How do you query documents where a field is greater than or equal to a value?
5.) Which operator is used to match multiple conditions that must all be true?
6.) Which MongoDB operator negates the condition?
7.) What is the function of the $or operator in MongoDB?
8.) How do you exclude a field in a query result using projection?
9.) Which of the following operators checks whether a field exists in a document?
10.) How do you query documents where a field value is not in a specified array?