From the course: MongoDB C# Developer Associate Cert Prep

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

MongoDB CRUD operations: Modifying query results review

MongoDB CRUD operations: Modifying query results review - MongoDB Tutorial

From the course: MongoDB C# Developer Associate Cert Prep

MongoDB CRUD operations: Modifying query results review

- In this unit, we learned to modify query results with MongoDB. We first saw how to return query results in a specified order using the cursor.sort() method. The sort method takes a sort document parameter that defines the sort order of the results set. We also saw how to constrain the number of results using the cursor.limit() method. The limit method takes an argument for the maximum number of documents to return. Remember that limiting results can enhance the performance of your application by avoiding unnecessary data processing. We then practiced returning selected fields from a query using projection. We saw how to specify fields to return by adding a projection document as a second parameter in calls to the .find() method. We now know that inclusion and exclusion statements can't be combined in most projections, with the exception of the _id field. We can choose to exclude the _id field in any projection, including…

Contents