On Fri, Aug 5, 2011 at 15:00, Matthew Slade <[email protected]> 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. -Randall
