On Friday, June 6, 2014 11:12:13 AM UTC+2, Pelle Krøgholt wrote:
>
>
>
> On Thursday, June 5, 2014 7:16:20 PM UTC+2, Matt Quinn wrote:
>>
>> On Thu, Jun 05, 2014 at 03:06:05AM -0700, Pelle Krøgholt wrote: 
>> > how to do the same with the above $ajax/uri approach? i have tried: 
>> > 
>> > > var startKey = 
>> > encodeURIComponent('["969aee54-76e0-46c7-a585-fa5c13d619d6", {}]') 
>> > > var endKey = 
>> > encodeURIComponent('["969aee54-76e0-46c7-a585-fa5c13d619d6"]') 
>> > > $.ajax({ 
>> >     type: "GET", 
>> >     url: 
>> > "http://localhost:5984/todo/_design/todo9/_view/tasks?startKey="+startKey+"&endKey="+endKey,
>> >  
>>
>> >     contentType: "application/json", 
>> >     success: function (msg) { console.log('succes: ', msg) }, 
>> >     error: function (err){ console.log('error: ', err)} 
>> >     }); 
>> > succes: 
>> > Object {offset: 0, total_rows: 7, rows: Array[7]} 
>> > 
>> > hmm but that gives me 7 tasks i had only expected 6 - any 
>> hints/suggestions 
>> > ? 
>>
>> I think this is because of your query string parameters names. Can you 
>> try it again using "startkey" and "endkey" (all lower case)? 
>>
>
> thanks for the suggestion - when I try with lowercase I get unfortunately 
> an empty result:
>
> $.ajax({
>     type: "GET",
>     url: "
> http://localhost:5984/todo/_design/todo9/_view/tasks?startkey=%5B%22969aee54-76e0-46c7-a585-fa5c13d619d6%22%2C%20%7B%7D%5D&endkey=%5B%22969aee54-76e0-46c7-a585-fa5c13d619d6%22%5D
> ",
>     contentType: "application/json",
>     success: function (msg) { console.log('succes: ', msg) },
>     error: function (err){ console.log('error: ', err)} 
> });
> succes:  
> Object {offset: 0, total_rows: 0, rows: Array[0]}
>
>
> //
>
> pelle
>

ok once again thanks matt for pointing me in the right direction - i must 
have been a bit dizzy when I look at it again with fresh eyes.

solution: lowercase startkey and endkey + descending=true

and now i get the 6 items as expected:

$.ajax({
    type: "GET",
    url: 
'http://localhost:5984/todo/_design/todo9/_view/tasks?startkey=["969aee54-76e0-46c7-a585-fa5c13d619d6";,
 
{}]&endkey=["969aee54-76e0-46c7-a585-fa5c13d619d6"]&descending=true',
    contentType: "application/json",
    success: function (msg) { console.log('succes: ', msg)},
    error: function (err){ console.log('error: ', err)} 
});
succes:  
Object {offset: 0, total_rows: 6, rows: Array[6]}

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/ca1cfdb1-98ea-4055-85af-1ae8c0398810%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to