Answer the question
In order to leave comments, you need to log in
How to sort mongoose products by multiple parameters?
We need mongoose to sort by several parameters, depending on what the user chooses. For example, by price and name, by type and price.
Answer the question
In order to leave comments, you need to log in
Use aggregations.
MongoDB Compass even has an Aggregation Pipeline Builder so you don't have to code to try it out.
Well, in mongoose it is
Model.aggregate()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question