Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8945833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:20:56+00:00 2026-06-15T12:20:56+00:00

The view function below is used to emit some entries: function(doc) {emit(null,{date:doc.date,title:doc.title,txt:doc.txt});} {total_rows:7,offset:0,rows:[ {id:67ebe3755be4edf5c4edf0d96f0023eb,key:null,value:{date:Dec

  • 0

The view function below is used to emit some entries:

function(doc) {emit(null,{"date":doc.date,"title":doc.title,"txt":doc.txt});}

{"total_rows":7,"offset":0,"rows":[
{"id":"67ebe3755be4edf5c4edf0d96f0023eb","key":null,"value":{"date":"Dec 12,2012","title":"test1","txt":"this is just a test"}},
{"id":"67ebe3755be4edf5c4edf0d96f003120","key":null,"value":{"date":"Nov 11,2012","title":"test2","txt":"this is just a test2"}},
{"id":"67ebe3755be4edf5c4edf0d96f003869","key":null,"value":{"date":"Dec 22,2012","title":"test4","txt":"this is just a test4"}},
{"id":"67ebe3755be4edf5c4edf0d96f003cfd","key":null,"value":{"date":"Aug 21,2010","title":"test5","txt":"this is just a test5"}},
{"id":"67ebe3755be4edf5c4edf0d96f004466","key":null,"value":{"date":"Nov 1, 2010","title":"test6","txt":"this is just a test6"}},
{"id":"67ebe3755be4edf5c4edf0d96f004d9c","key":null,"value":{"date":"Aug 15,2010","title":"test7","txt":"this is just a test7"}},
{"id":"67ebe3755be4edf5c4edf0d96f005d04","key":null,"value":{"date":"Feb 28,2012","title":"test3","txt":"this is just a test3"}}
]}

What is the best way to group the entries by year and month using CouchDB functions?

(to format output in JSON like:)

{
"2012":{
    "Feb":[{"date":"Feb 28,2012","title":"test3","txt":"this is just a test3"}],
    "Nov":[{"date":"Nov 11,2012","title":"test2","txt":"this is just a test2"}],
    "Dec":[{"date":"Dec 12,2012","title":"test1","txt":"this is just a test"},
        {"date":"Dec 22,2012","title":"test4","txt":"this is just a test4"}]    

    },

"2010":{
    "Aug":[{"date":"Aug 15,2010","title":"test7","txt":"this is just a test7"},
           {"date":"Aug 21,2010","title":"test5","txt":"this is just a test5"}],
    "Nov":[{"date":"Nov 1, 2010","title":"test6","txt":"this is just a test6"}] 

    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:20:57+00:00Added an answer on June 15, 2026 at 12:20 pm

    Your map function shoud look like this:

    function (doc) {
        var date = new Date(doc.date);
        emit([date.getFullYear(), date.getMonth()], doc);
    }
    

    Then when you query the view data, it will be sorted by date. if you add “descending=true”, then you’ll get them sorted backwards. And if you add “?startKey=[2012,””]&endkey=[2012]&descending=true”, then you’ll get all the documents with 2012 doc.date

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My function below calls a partial view after a user enters a filter-by string
Below is the code i'm looking at the moment. <s:View xmlns:fx=http://ns.adobe.com/mxml/2009 xmlns:s=library://ns.adobe.com/flex/spark title=data xmlns:model=model.*
The function below is what I used to display the contents of a table
below is the code i used everything works well EXCEPT for Deprecated: Function mysql_list_tables()
I used below code to render a page in the controller action. public function
I've got a view function that has to decide which form to use depending
I have the view function in django that written like a dispatcher calling other
I have a view function which needs to be manually transaction managed, but when
The View.remove() function in backbone js removes the container element of the view itself
I have code like this in my view model: function ChatListViewModel(chats) { var self

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.