couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randall Leeds <>
Subject Re: View collation by one key and sorting by another key
Date Fri, 05 Aug 2011 22:19:25 GMT
On Fri, Aug 5, 2011 at 15:00, Matthew Slade
<> wrote:
> Hi Zach (and everyone else)
> Thanks for the info. Unfortunately my game is already big and the proposed
> solution wouldn't really be suitable although _lists seem interesting and
> I'll definitely investigate them. I do find this quite a limitation to
> couchdb especially when one is working a lot with dated documents.
> Another question I have in a similar vein:
> Given a set of documents being created for transaction for the purchase of
> fruit for example.
> * {
> "_id":"uniqueOrderId",
> "dateOfPurchase": "2011-07-06T10:24:52",
> "itemId": "oranges"
> }*
> Could one collate the view entries by the date and then reduce based off of
> part of the value. ie How could I easily answer the question "*How many
> oranges were sold on Wednesday*?" efficiently with potentially huge numbers
> of transaction documents in my database.

You should separate the key you emit into an array of the date pieces
like [YYYY, MM, DD, ...].
Then you can use ?group_level=X with your reduce query to get hourly,
daily, monthly, etc summaries.


View raw message