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 7500105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:04:06+00:00 2026-05-29T20:04:06+00:00

Please help me to solve this. I’ve around 1500 documents in my CouchDB, each

  • 0

Please help me to solve this. I’ve around 1500 documents in my CouchDB, each document belongs to any one of the types (‘Survey’ and ’Response’).

I need solution for followings

1] Need to display Document Ids (_id) in a Dropdown list which has document type (documentType) as ‘Survey’

2] If I select an item (_id) from drop down, I need to display all document Ids (_id) in list box which belongs to selected ID (_id selected from drop down list)

I’ve total 1500 documents like this

{
   "_id": "ff2fb2554682ba613c2f83c63502808a",
   "_rev": "4-dd559696434a402739e789ccc8c9a481",
   "answers": [
       {
           "answers": [
               "Aug 19,2011"
           ],
           "questionId": "50f3df434ae02ac7fff48c1c2bde83e4"
       },
       {
           "answers": [
               "Bechu Yadav"
           ],
           "questionId": "15504f006e58872fd94871fe0c9d32ad"
       },
       {
           "answers": [
               "35"
           ],
           "questionId": "3c447a2f5cc6ca1985ce2c81463a3c47"
       },
       {
           "answers": [
               "Male"
           ],
           "questionId": "a6df7c25602939554612ef6de762f5b9"
       },
       {
           "questionId": "2f66155965e60094f23f01af531d5af1",
           "subAnswers": [
               {
                   "questionId": "1dae2d86eef846c967254c9e369170ce"
               },
               {
                   "questionId": "40ffeb4d33dab1fe8d2d8b73c02ed13b"
               },
               {
                   "questionId": "2db1e8b6e97d5baa8935b9b31fcc9648"
               },
               {
                   "questionId": "0f8bb9f91ea8085b4ffb839ee8deabb5"
               },
               {
                   "questionId": "22a93ecb72c50ff8899f8b2937776e51"
               },
               {
                   "questionId": "e5106384790c2be745c952c4b867a0ff"
               }
           ]

           "questionId": "492cf9bd41257ea478c5222fbba06616"
       }
   ],
   "createdAt": "2011-08-19T21:05:36.486+0000",
   "createdBy": "user4",
   "documentType": "Response",
   "ipAddress": "42.110.85.67",
    "location": {
       "latitude": 26.8415613,
       "longitude": 75.8222883,
       "provider": "network"
   },
    "surveyId": "6df022f0f371752167ad4920b38e1c37",
    "published": true
}

And my CouchRest model looks like as follows

class Android < CouchRest::Model::Base
    property :description, String
    property :_id, String
    property :_rev, String
    property :documentType, String

    design do
      view :by_documentType,:map =>"function(doc){if (doc.documentType == 'Survey') {emit(doc._id);}}"
      view :by_createdBy
    end
 end

But when I access by_documentType it’s returning nil

Android.find_by_documentType('Survey')
  • 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-05-29T20:04:07+00:00Added an answer on May 29, 2026 at 8:04 pm

    Thanks Friends!

    Finally I found the Answer, I changed my Model as follows

    require 'couchrest_model'
    
    class Android < CouchRest::Model::Base
    
      property :description, String
      property :_id, String
      property :_rev, String
      property :documentType, String
      property :surveyId, String
    
      design do
        view :by_document_type,:map =>"function(doc) {if (doc.documentType == \"Survey\") {emit([doc._id,doc.title], 1);}}",:reduce=>"function(keys, values, rereduce) {return sum(values);}"
        view :by_surveyId,:map =>"function(doc) {emit([doc.surveyId], 1);}",:reduce=>"function(keys, values, rereduce) {return sum(values);}"
      end
    end
    

    And now able to call this view as required. following returns all the documents which has document type ‘Survey’

    Android.by_document_type.rows
    

    And Based on Survey ID selection, I can retrieve all documents which belongs to selected survey id, as follows

    Android.by_surveyId.key('Selected Survey ID goes here').rows
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please any one help to solve, how to get hoptoad/airbrake Error Notification in Development
I have a long string, ex: Please help me to solve this problem. This
Was wondering if somebody could please help me solve this. I've follwed all steps
Could someone please help solve this problem?
please help me solve this issue. I have a client using WCF. I don't
Please help me solve this file path conflict: As you know, many HTML pages
Please help to solve this small problem: I try to decode incoming jpg data
please help my solve this error i get when i try to archive my
Please help solve this: Telephone numbers are often given out as a word representation,
Please help me solve this exception:- String strBinary=100000000000000001000000000000000000000000000000000000000000000000000000; System.out.println(length is + strBinary.length()); long intParse=Long.parseLong(strBinary,

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.