How to sort data using MongoDB Compass

I am currently trying to use MongoDB Compass to query my collection. However, I seem to be able to only filter the data.

Is there a way to sort the data? I would like to sort my data in ascending order using one of the data fields.

If MongoDB Compass is not the best way to order a collection, what other GUI can I use?

+3


source to share


1 answer


Using MongoDB Compass 1.7 or newer, you can sort (and design, skip or limit) the results by selecting the Documents tab and expanding Options .

enter image description here



To sort in ascending order by field myField

, use { myField:1 }

. Any of the usual cursor sorting options () can be supplied, including ordering results by multiple fields.

Note. Options such as sort and skip are not available on the Schemas tab by default, as this view uses sampling to find a random set of documents, rather than Documents which displays a specific query result.

+3


source







All Articles