F
F
friktor2014-05-17 12:18:27
JavaScript
friktor, 2014-05-17 12:18:27

How to make working sorting in SailsJS?

on the page I wanted to make a selection for display in descending order - from the identifier. ended up with code like this

index: function (req, res, next) {
    Post.find()
      .sort({
        id: 'desc'
      })
      .exec(function (err, posts) {
        if (err) return res.send(500);
        res.view({
          posts: posts
        });
      });
  }

Reflection happens - but sorting is not done, what is my mistake?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rsludge, 2014-05-18
@friktor

sort('id DESC')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question