Minimongo sort collection by text term but dont query by text term?


#1
  • I don’t want to sort alphabetically
  • I don’t want to query/filter {title: myExactSearchTerm}
  • I want to show all results, but I want them sorted with those holding myExactSearchTerm first, with the others following

is this possible with mongo/minimongo?


#2

Since you are saying you want to show all results, how about this:

db.collection.find().fetch().sort(function(a,b){
    if (a === myExactSearchTerm){
        return 1
    } else {
        return -1
    }
})

#3

thanks!!!