couchdb offset: I get no results -


i make ajax request couchdbwith post method, giving list of keys of docs want retrieve.

everything seems work fine except fact 0 rows because offset set on last line.

so means that:

  1. i'm communicating couchdb server (cloudant)
  2. the post method works
  3. it seems retrieve list giving offest of last element, i.e. empty list

also, trying order results differently had no success.

rilist var (from google chrome dev tools):

keys: array[194] 0: "wire line diamond core drilling rig" 1: "vua - isotope geochemistry laboratory" 2: "volcanologic , seismological observatories" 3: "vesog" 4: "utrecht university - teclab, tectonic laboratory" 5: "utrecht university - experimental , analytical laboratories" ..... 

which same of

var rilist=["wire line diamond core drilling rig", "vua - isotope geochemistry laboratory","volcanologic , seismological observatories","vesog","utrecht university - teclab, tectonic laboratory","utrecht university - experimental , analytical laboratories"]; 

here code

            var rilist= listofru.pluck('ri_name');             var queryparams={"keys":rilist};             var riresponselist=[];             var ajaxurl= ('_view/'+ self.parentmcdropdownvalue);             console.log(ajaxurl, queryparams);             $.ajax({ //retrieve , show on map laboratory coordinates                 async: true,                  url: ajaxurl,                 type:"post",                 data:json.stringify(queryparams),                 datatype: 'json',                 timeout:5000,                 success:function(response){                     console.log("response",response);                     riresponselist=response.rows;                     },                 error:function(){                     alert('fetching error');                     }                 }); 

chrome developer tools output

response  object offset: 194 rows: array[0] total_rows: 194 __proto__: object 

as can see in output of chrome devtools offset 194 have array 0 rows because starts last key.

any idea?

i tempted delete question when found bug.

but decided let , explain wrong.

if feel should deleted, please motivate , i'll delete it.

so answer question simple: keys retrieving not keys selecting "keys" parameter.

the error indeed in map function wrote:

//wrong one!! function(doc){     if(doc.doctype=='ri'){         emit(doc.ri, doc);     } } 

instead of

//right one!! function(doc){     if(doc.doctype=='ri'){         emit(doc.ri_name, doc);// ri_name instead of ri!!!!!     } } 

so lesson is:

when offset equals lenght of array, check if results 1 want obtain map function.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -