0

The below query (without using sort) works well.

return Cars.find({ carColor : {$in: ["Black","Blue","Red","White","Silver","Orange"]}, carType : {$in: ["Subaru","Toyota","Aston Martin","BMW"]} ,  carPrice: { $lte: maximumPrice} })

but once I insert the sort method (seen at the end of the statement), it does not work.

return Cars.find({ carColor : {$in: ["Black","Blue","Red","White","Silver","Orange"]}, carType : {$in: ["Subaru","Toyota","Aston Martin","BMW"]} ,  carPrice: { $lte: maximumPrice} }).sort( { carPrice: 1 } )

I've tried sorting the query using many different tactics but none seem to work. I'm using mongodb3.2 .

Here is my insert:

Cars.insert({
  carType : carType,
  carColor : carColor,
  carPicture : carPicture,
  carStyle : carStyle,
  carPrice : carPrice, //store it as a number
  date : new Date
})

Thank you all in advance, much appreciated.

Community
  • 1
  • 1
wyattwade
  • 38
  • 4
  • 1
    Meteor applies "sort" in a different way. Also simply answered by ["Meteor how to sort"](https://www.google.com/search?q=meteor+how+to+sort&ie=utf-8) as a search. Using the first result on stackoverflow that shows a valid example usage. – Blakes Seven Mar 25 '16 at 21:05
  • @BlakesSeven , This worked well first try after finding multiple solutions that didn't work over the past hour. I have to thank you man, and yes this question is a duplicate. A little new to stackoverflow so not sure if I should delete the question. But again, thanks a lot. – wyattwade Mar 25 '16 at 21:08
  • @wyattwade You should. – Quirk Mar 25 '16 at 21:10
  • 2
    @Quirk Considering the phrase use **is not** the very first search result pointing to an answer on stackoverflow I disagree. Just because a question is marked as "duplicate" does not mean it gets deleted. Good to keep those titles for SEO you know. So it "should" be left to moderation. – Blakes Seven Mar 25 '16 at 21:13

0 Answers0