Specifies the sort criteria for selecting documents.
If you want stricter type-checking and full auto-complete, see StrictSort.
Can use 1/-1 for ascending/descending, or $vector for sorting by vector distance.
1
-1
$vector
See SortDirection for all possible sort values.
NB. The order of the fields in the sort option is significant—fields are sorted in the order they are listed.
// Sort by name in ascending order, then by age in descending orderconst sort1: Sort = { name: 1, age: -1,}// Sort by vector distanceconst sort2: Sort = { $vector: [0.23, 0.38, 0.27, 0.91, 0.21],} Copy
// Sort by name in ascending order, then by age in descending orderconst sort1: Sort = { name: 1, age: -1,}// Sort by vector distanceconst sort2: Sort = { $vector: [0.23, 0.38, 0.27, 0.91, 0.21],}
Specifies the sort criteria for selecting documents.
If you want stricter type-checking and full auto-complete, see StrictSort.
Can use
1
/-1
for ascending/descending, or$vector
for sorting by vector distance.See SortDirection for all possible sort values.
NB. The order of the fields in the sort option is significant—fields are sorted in the order they are listed.