Q:

How to get parameter value in views of coauchbase

I have a document called login_data like-
{
   "name": "abc",
   "password": "abcd123",
   "user_id": "abc123"
}

and I am creating a view for checking the user_id and password is correct or not which is cumming from the URL.
And the code of view like-
function (doc, meta) { 
  if(doc.password && doc.user_id){
      emit("Status","Sucess");     
  }  
}

and my URL is like :-
http://localhost:8092/default/_design/dev_design/_view/login_credential?stale=false&inclusive_end=true&connection_timeout=60000&limit=10&skip=0&password=%22abcd123%22&user_id=%22abc123%22
So how to get the param values in the views.Is there any other way to do this ,if any please suggest.
Thanks in advance.

A:

I think you're confused about what to emit and how to query a view.
The view is basically a simple index. First parameter of emit in the map function is the index key, and that is what you will use to query the view. Second parameter is an optional value associated with the key, upon which the reduce function can be run, to get statistics or an overall value for all documents matched by your view query...
Possible GET parameters of a view query are strictly defined, you cannot query arbitrary fields of the document if they are not part of this key you emitted.
For that you should look at N1QL in Couchbase 4.0 and 4.1 instead.

