M
M
magamed_deni2021-08-08 14:32:48
Mongoose
magamed_deni, 2021-08-08 14:32:48

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

1 answer(s)
R
Rag'n' Code Man, 2021-08-09
@iDmitriyWinX

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 question

Ask a Question

731 491 924 answers to any question