I am trying to generate a response that returns the same collection sorted by 3 different columns. Here's the code I currently have:
var findRoute = router.route("/find")
findRoute.get(function(req, res) {
Box.find(function(err, boxes) {
res.json(boxes)
}).sort("-itemCount");
});
As you can see, we're making a single get request, querying for the Boxes, and then sorting them by itemCount
at the end. This does not work for me because the request only returns a single JSON collection that is sorted by itemCount
.
What can I do if I want to return two more collections sorted by, say, name
and size
properties -- all in the same request?