incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Slade <>
Subject View collation by one key and sorting by another key
Date Fri, 05 Aug 2011 14:27:59 GMT
Hi All

I've been struggling with creating a view for my game's weekly leaderboard.
For simplicities sake lets assume my player document is structured in
the following way:

"lastDateActive": "2011-07-06T10:24:52",
"numberOfKills": 50

If I create a map function with the "lastDateActive" as the key I can
use a start and an end key to collate the data and to only count users
that fall within the last week.

If I create a map function with the "numberOfKills" as the key the
data is automatically ordered for me by kills meaning I can specify a
limit of 10 in the options and successfully pull out only the top 10

But If I create a complex key with either of these fields as the first
key I am unable to collate or order the data successfully since the
ordering can only satisfy one of the above conditions not both.

Is there anyway that one could successfully merge these two
requirements and perform this sort of operation where data is collated
by 1 key and sorted by another?

Thank you in advance for your time and help


View raw message