You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Tristan Sloughter <tr...@gmail.com> on 2011/02/26 18:55:33 UTC

Last 10 documents

I was hoping with descending being true and limit=10 I could get the last 10
documents in a view.

It does not seem to work for me, is there a way to get the last X results in
a view without knowing the keys?

Thanks,
Tristan

Re: Last 10 documents

Posted by Tristan Sloughter <tr...@gmail.com>.
Yeah, sorry, I went and did some manually testing right before I got this
and you are right. It does work and something must be wrong else where.

Thanks,
Tristan

On Sat, Feb 26, 2011 at 12:03 PM, Robert Newson <ro...@gmail.com>wrote:

> Using skip as suggested would be bad, yes.
>
> ?descending=true&limit=10 should do what you want, are you sure you're
> passing the parameters correctly? If using curl, it's a common mistake
> not pass the & character (which backgrounds the task  and everything
> after it is ignored). So put the whole url in single quotes. e.g;
>
> curl 'localhost:5984/pathtoview?descending=true&limit=10'
>
> B.
>
> On 26 February 2011 13:01, Tristan Sloughter
> <tr...@gmail.com> wrote:
> > My understanding is skip should only be used with large numbers. If I
> have
> > thousands of documents that would be bad, right?
> >
> > Tristan
> >
> > On Sat, Feb 26, 2011 at 11:59 AM, Alexander Uvarov <
> > alexander.uvarov@gmail.com> wrote:
> >
> >> Use ?skip=X where X = N - 10
> >>
> >> N = count of documents (using reduce)
> >>
> >> On Sat, Feb 26, 2011 at 10:55 PM, Tristan Sloughter
> >> <tr...@gmail.com> wrote:
> >> > I was hoping with descending being true and limit=10 I could get the
> last
> >> 10
> >> > documents in a view.
> >> >
> >> > It does not seem to work for me, is there a way to get the last X
> results
> >> in
> >> > a view without knowing the keys?
> >> >
> >> > Thanks,
> >> > Tristan
> >> >
> >>
> >
>

Re: Last 10 documents

Posted by Robert Newson <ro...@gmail.com>.
Using skip as suggested would be bad, yes.

?descending=true&limit=10 should do what you want, are you sure you're
passing the parameters correctly? If using curl, it's a common mistake
not pass the & character (which backgrounds the task  and everything
after it is ignored). So put the whole url in single quotes. e.g;

curl 'localhost:5984/pathtoview?descending=true&limit=10'

B.

On 26 February 2011 13:01, Tristan Sloughter
<tr...@gmail.com> wrote:
> My understanding is skip should only be used with large numbers. If I have
> thousands of documents that would be bad, right?
>
> Tristan
>
> On Sat, Feb 26, 2011 at 11:59 AM, Alexander Uvarov <
> alexander.uvarov@gmail.com> wrote:
>
>> Use ?skip=X where X = N - 10
>>
>> N = count of documents (using reduce)
>>
>> On Sat, Feb 26, 2011 at 10:55 PM, Tristan Sloughter
>> <tr...@gmail.com> wrote:
>> > I was hoping with descending being true and limit=10 I could get the last
>> 10
>> > documents in a view.
>> >
>> > It does not seem to work for me, is there a way to get the last X results
>> in
>> > a view without knowing the keys?
>> >
>> > Thanks,
>> > Tristan
>> >
>>
>

Re: Last 10 documents

Posted by Tristan Sloughter <tr...@gmail.com>.
My understanding is skip should only be used with large numbers. If I have
thousands of documents that would be bad, right?

Tristan

On Sat, Feb 26, 2011 at 11:59 AM, Alexander Uvarov <
alexander.uvarov@gmail.com> wrote:

> Use ?skip=X where X = N - 10
>
> N = count of documents (using reduce)
>
> On Sat, Feb 26, 2011 at 10:55 PM, Tristan Sloughter
> <tr...@gmail.com> wrote:
> > I was hoping with descending being true and limit=10 I could get the last
> 10
> > documents in a view.
> >
> > It does not seem to work for me, is there a way to get the last X results
> in
> > a view without knowing the keys?
> >
> > Thanks,
> > Tristan
> >
>

Re: Last 10 documents

Posted by Alexander Uvarov <al...@gmail.com>.
Use ?skip=X where X = N - 10

N = count of documents (using reduce)

On Sat, Feb 26, 2011 at 10:55 PM, Tristan Sloughter
<tr...@gmail.com> wrote:
> I was hoping with descending being true and limit=10 I could get the last 10
> documents in a view.
>
> It does not seem to work for me, is there a way to get the last X results in
> a view without knowing the keys?
>
> Thanks,
> Tristan
>