You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Steven Prentice <st...@gmail.com> on 2010/07/22 04:13:31 UTC

querying an array view with startkey and endkey

Hi couchers

say I have the following keys: ["file", "FileA", "folder", "folderA"]
["file", "FileA", "null", "null"] ["file", "FileB", "folder", "folderB"]
I want to use startkey=["file", "FileA"] to find all the fileA documents
regardless of if they have folders or not. But I don't want any FileB's
showing up afterwards!
I can't put endkey=["file", "fileB"] because I am not going to know that
fileB is the next id in the view before I make the request, it could be
anything!

Basically I am looking ot find out how to limit the view to only keys that
start with ["file", "FileA"]. Is there some sort of 'special character' I
could put into endkey or something to do so?

p.s my aim is to not have to make another view that has a smaller key of
["file", "fileID"]

Cheers
Steve

Re: querying an array view with startkey and endkey

Posted by Robert Newson <ro...@gmail.com>.
http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options

inclusive_end = true/false, default is true.

On Wed, Jul 21, 2010 at 10:33 PM, Steven Prentice
<st...@gmail.com> wrote:
> Thanks Randall!
> ...I wonder why developers dont make endkey inclusive? or allow limit to
> specify a key or some sort of functionality like that...I would be more
> relaxed thats for sure haha
>
> On Thu, Jul 22, 2010 at 12:29 PM, Randall Leeds <ra...@gmail.com>wrote:
>
>> http://wiki.apache.org/couchdb/View_collation
>>
>> Your answer is there :)
>>
>> startkey=["file", "fileA"]
>> endkey=["file", "fileA\ufff0"]
>>
>> Cheers!
>> Randall
>>
>> On Jul 21, 2010 7:18 PM, "Steven Prentice" <st...@gmail.com>
>> wrote:
>>
>> Hi couchers
>>
>> say I have the following keys: ["file", "FileA", "folder", "folderA"]
>> ["file", "FileA", "null", "null"] ["file", "FileB", "folder", "folderB"]
>> I want to use startkey=["file", "FileA"] to find all the fileA documents
>> regardless of if they have folders or not. But I don't want any FileB's
>> showing up afterwards!
>> I can't put endkey=["file", "fileB"] because I am not going to know that
>> fileB is the next id in the view before I make the request, it could be
>> anything!
>>
>> Basically I am looking ot find out how to limit the view to only keys that
>> start with ["file", "FileA"]. Is there some sort of 'special character' I
>> could put into endkey or something to do so?
>>
>> p.s my aim is to not have to make another view that has a smaller key of
>> ["file", "fileID"]
>>
>> Cheers
>> Steve
>>
>

Re: querying an array view with startkey and endkey

Posted by Steven Prentice <st...@gmail.com>.
Thanks Randall!
...I wonder why developers dont make endkey inclusive? or allow limit to
specify a key or some sort of functionality like that...I would be more
relaxed thats for sure haha

On Thu, Jul 22, 2010 at 12:29 PM, Randall Leeds <ra...@gmail.com>wrote:

> http://wiki.apache.org/couchdb/View_collation
>
> Your answer is there :)
>
> startkey=["file", "fileA"]
> endkey=["file", "fileA\ufff0"]
>
> Cheers!
> Randall
>
> On Jul 21, 2010 7:18 PM, "Steven Prentice" <st...@gmail.com>
> wrote:
>
> Hi couchers
>
> say I have the following keys: ["file", "FileA", "folder", "folderA"]
> ["file", "FileA", "null", "null"] ["file", "FileB", "folder", "folderB"]
> I want to use startkey=["file", "FileA"] to find all the fileA documents
> regardless of if they have folders or not. But I don't want any FileB's
> showing up afterwards!
> I can't put endkey=["file", "fileB"] because I am not going to know that
> fileB is the next id in the view before I make the request, it could be
> anything!
>
> Basically I am looking ot find out how to limit the view to only keys that
> start with ["file", "FileA"]. Is there some sort of 'special character' I
> could put into endkey or something to do so?
>
> p.s my aim is to not have to make another view that has a smaller key of
> ["file", "fileID"]
>
> Cheers
> Steve
>

Re: querying an array view with startkey and endkey

Posted by Randall Leeds <ra...@gmail.com>.
http://wiki.apache.org/couchdb/View_collation

Your answer is there :)

startkey=["file", "fileA"]
endkey=["file", "fileA\ufff0"]

Cheers!
Randall

On Jul 21, 2010 7:18 PM, "Steven Prentice" <st...@gmail.com>
wrote:

Hi couchers

say I have the following keys: ["file", "FileA", "folder", "folderA"]
["file", "FileA", "null", "null"] ["file", "FileB", "folder", "folderB"]
I want to use startkey=["file", "FileA"] to find all the fileA documents
regardless of if they have folders or not. But I don't want any FileB's
showing up afterwards!
I can't put endkey=["file", "fileB"] because I am not going to know that
fileB is the next id in the view before I make the request, it could be
anything!

Basically I am looking ot find out how to limit the view to only keys that
start with ["file", "FileA"]. Is there some sort of 'special character' I
could put into endkey or something to do so?

p.s my aim is to not have to make another view that has a smaller key of
["file", "fileID"]

Cheers
Steve