tornado - MongoDB Order by two columns -


does know how can sort tables 2 values?

for example :

i have stats collections has columns "_id", "title", "link", "stats", "range". "stats" column consist values ['duration','pace', 'distance'], "range" column consist velues 0-10 km, 20-20 min on depend of stats values.

i'd order stats , after range .

this link

in link above i've sorted stats , want sort range each value of stats!

my current code :

guides = yield gen.task(guides.objects.find, query={}, limit=20,                             sort={'stats': 1}) 

to order documents more 1 field, need compound sort statement , ideally compound index backing it.

for compound indexes in mongodb see: http://docs.mongodb.org/manual/tutorial/create-a-compound-index/

your sort like:

guides = yield gen.task(guides.objects.find, query={}, limit=20,                         sort={'stats': 1, 'range': 1}) 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -