M001-Chapter 4-Lab 1: Logic Operators - If you want to see selected fields only (projection) and Sorting the result

Hi everyone. Please, let me share with you this tip in the way we are learning MQL

As documents usually have a lot of fields, you can check your query in this way, so you can select some field only and sort the result as well:

  • To see only some fields you can use the projection parameter in this way: {“field” :1}
  • To sort the cursor (the result´s query) you can use .sort({“field”:1}) at the end of your query. In this case ascending sort.