Unable to pass Dynamic parameter value to a map function in CouchDB #4134
Replies: 4 comments 1 reply
-
Hi Preethi, this will not work! You cannot change the method signature. Ich vermutet, du möchtest dir alle Angestellten auflisten lassen. Dazu könntest du zum Beispiel in deinen Datensätzen ein Attribute
If you now want to list all employees, you could use this map function (only an example:
This will emit something like this, if you call your view:
This would show you all of your employees order by their last name in ascending order. You can read more about views in our docs, e.g. https://docs.couchdb.org/en/stable/ddocs/views/index.html |
Beta Was this translation helpful? Give feedback.
-
Hi Preethi, no this is not possible. You can create multiple design documents or you can create multiple views within one design document. So you can construct a view for a company and a view for employees. I don't think it's a good idea to mix those in one ddoc, because they have different data in it. An other way to do a "dynamic" query is to use the But I'm only guessing at the moment, so can you explain to me what exactly you want to do? |
Beta Was this translation helpful? Give feedback.
-
I have the following document inside couchdb. Now I want to retrieve value for batters.batter.id == 1003 when the type specified by the user is batters. And I want to retrieve value for toppings.id == 5001 when the type specified by the user is topping. Can this be possible without using index in the query? Point to be noted is that : the json structure can be nested as much as possible and still the dynamic query needs to be constructed. {
"items":{
"item":[
{
"id":"0001",
"batters":{
"batter":[
{
"id":"1003",
"type":"Blueberry"
},
{
"id":"1004",
"type":"Devil's Food"
}
]
},
"topping":[
{
"id":"5001",
"type":"None"
},
{
"id":"5002",
"type":"Glazed"
}
]
}
]
}
} |
Beta Was this translation helpful? Give feedback.
-
So if you "search" for |
Beta Was this translation helpful? Give feedback.
-
Description
I want to pass a dynamic parameter value to the Couchdb map function. But it is failing when additional parameters except doc are passed. Please specify If there is a way to pass a dynamic value to the map function parameter in CouchDB to do some processing inside the function.
Steps to Reproduce
[1] Create a design document and Create a view
[2] Add the following code to the map function.
Expected Behaviour
To pass the employees variable to the view as a parameter.
NOTE: # ( Tell us what you expected to happen. )
I wanted to have dynamic value to be passed to the map function of a view in CouchDB.
Your Environment
Additional Context
Beta Was this translation helpful? Give feedback.
All reactions