_view shows 404 not found error

mobile

#1

Hello Team,
I have used Couchbase-Lite-PhoneGap-Plugin plugin in sencha touch. I have used rest API’s to read write the data in CB database.
Implementaion steps:
Request URL: http://e223578e-0d56-41b7-84e6-560390315141:6cda07f0-c908-45c1-8080-d4b38f627410@localhost:5984/dbName

  1. Created database
    PUT : …/@localhost:5984/dbName
    Status: 200 succecss

  2. Create Design documents
    PUT: …/dbName/_design/designDocName
    Request Param :
    {
    xyz:{
    map: function(doc){
    if(doc.type == “xyz”){
    emit(doc.id, doc);
    //emit(doc.name, doc);// if required
    }
    }.toString()
    }
    }
    status : 200 success

  3. Write data in DB:
    POST : …/dbName/_bulk_docs
    Status Code: 200 success.
    var docs = {
    “docs” : records,
    “new_edits” : true,
    };
    Here records is array or data in following format
    {
    _id: 1,
    type: ‘xyz’,



    }

  4. Retrive data form database
    GET : …/dbName/_design/designDocName/_view/xyz
    Status Code: 404 Not found
    The step 4 always return 404 error. Please correct me if anything wrong in above request or suggest wat to get the data form couchbase.


#2

Your design document is wrong. The xyz property needs to be nested inside a _view property. Check the REST API docs.


#3

Thank you, jens I will wrap the mapping in view property.


#4

Hi @jens ,
I have changes design document as follows:
{
views:{
xyz:{
map: function(doc){
if(doc.type == “xyz”){
emit(doc.id, doc);
//emit(doc.name, doc);// if required
}
}.toString()
}
}
}

Still not able to fetch the documents. Now it returns 200 with 0 records in view and design document in get_all_docs

Retrive data form database
GET : …/dbName/_design/designDocName/_view/xyz
Status Code: 200
The step 4 return {“total_rows”:0,“offset”:0,“rows”:[]}.

I have also tried to get all documents using following api
GET : …/dbName/_all_docs
Status Code: 200
response: {
offset :0
doc:null
id:"_design/designDocName"
key:"_design/designDocName"
value:{_conflicts: Array(0), rev: “1-5f468ba8f7558e9cd52c63aad2023eef”}
total_rows:1
}

Please help me to fetch the data from couchbase.