T
T
testguaran2016-06-21 19:22:01
JavaScript
testguaran, 2016-06-21 19:22:01

How to get sorted data from the database in sails?

More precisely, I know how to get it, but how to get sorted data without regard to case?
In mongo, this is done like this:

db.getCollection('myCollection').aggregate([
{ "$project": {
   "name": 1,
   "insensitive": { "$toLower": "$name" }
}},
{ "$sort": { "insensitive": 1 } }
])

Can you tell me what I need to change in my code to make it work?
var param = {
        name: { 'contains': search.id },
        text: { 'contains': search.text },
        summary: { 'contains': search.summary },
        limit: limit,
        skip: skip,
        sort: sort
    };
    var cursor = News.find(param).populateAll();
        cursor.exec(function (err, n) {
            if (err) {
                console.log(err);
            }
            News.count(param).exec(function (error, count) {
                next({ data: n, total: count });
            });
        });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly, 2016-06-21
@vshvydky

if there is a solution for mongodb, can you use it until you realize how to implement it through the waterline? Link to my thought I
haven’t delved deeper yet, therefore I won’t tell you more

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question