You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Kevin Burton <rk...@charter.net> on 2012/11/06 22:58:01 UTC

Get all documents of a certain type.

In my Couch database I have a mixture of documents. The documents that I am
interested in have an Id of 'product-xxxxxxx' or 'order-xxxxxx'. The
"product" documents have a property of SKU that is a string. I would like to
form a query to get a list of all the product SKUs. Does this require a view
in the design document or can it be done all in one request? Thank you.


Re: Get all documents of a certain type.

Posted by Dustin Sallings <du...@spy.net>.
Mark Hahn <ma...@hahnca.com> writes:

> A view that emitted (_id, sku) would be the easiest and most efficient way
> to do it.  You wouldn't have to include_docs.

  Just (doc.sku, null) in this case.  It rarely makes sense to include
the doc ID in your view.

-- 
dustin


Re: Get all documents of a certain type.

Posted by Mark Hahn <ma...@hahnca.com>.
A view that emitted (_id, sku) would be the easiest and most efficient way
to do it.  You wouldn't have to include_docs.

On Tue, Nov 6, 2012 at 2:05 PM, Simon Metson <si...@cloudant.com> wrote:

> Hi,
> You can query with ?startkey=product&endkey=productZZZZ&include_docs=true
> to get all the product docs back.
>
> If they contain a lot more info than just the SKU's I'd make  a view.
> Cheers
> Simon
>
>
> On Tuesday, 6 November 2012 at 21:58, Kevin Burton wrote:
>
> > In my Couch database I have a mixture of documents. The documents that I
> am
> > interested in have an Id of 'product-xxxxxxx' or 'order-xxxxxx'. The
> > "product" documents have a property of SKU that is a string. I would
> like to
> > form a query to get a list of all the product SKUs. Does this require a
> view
> > in the design document or can it be done all in one request? Thank you.
>
>
>
>

Re: Get all documents of a certain type.

Posted by Jens Alfke <je...@couchbase.com>.
On Nov 6, 2012, at 2:05 PM, Simon Metson <si...@cloudant.com> wrote:

> You can query with ?startkey=product&endkey=productZZZZ&include_docs=true to get all the product docs back. 

To clarify, that query string should be used with the path “/db/_all_docs”.

—Jens

Re: Get all documents of a certain type.

Posted by Simon Metson <si...@cloudant.com>.
Hi, 
You can query with ?startkey=product&endkey=productZZZZ&include_docs=true to get all the product docs back. 

If they contain a lot more info than just the SKU's I'd make  a view.
Cheers
Simon


On Tuesday, 6 November 2012 at 21:58, Kevin Burton wrote:

> In my Couch database I have a mixture of documents. The documents that I am
> interested in have an Id of 'product-xxxxxxx' or 'order-xxxxxx'. The
> "product" documents have a property of SKU that is a string. I would like to
> form a query to get a list of all the product SKUs. Does this require a view
> in the design document or can it be done all in one request? Thank you.




Re: Get all documents of a certain type.

Posted by Dustin Sallings <du...@spy.net>.
"Kevin Burton" <rk...@charter.net>
writes:

>         emit([doc.SKU], null);

  I wouldn't think you'd need the key to be an array.  It's only one element.

-- 
dustin


Re: Get all documents of a certain type.

Posted by Mark Hahn <ma...@hahnca.com>.
Your image isn't showing in my browser, but all you have to do is select a
db and the drop down shows  with the label "View:"

On Tue, Nov 6, 2012 at 7:11 PM, Kevin Burton <rk...@charter.net>wrote:

> I don't see this drop-down.****
>
> ** **
>
> ****
>
> ** **
>
> -----Original Message-----
> From: Mark Hahn [mailto:mark@hahnca.com]
> Sent: Tuesday, November 06, 2012 9:00 PM
> To: user@couchdb.apache.org
> Subject: Re: Get all documents of a certain type.
>
> ** **
>
> > So how do I run the view?****
>
> ** **
>
> Choose it from the drop-down list of views.****
>
> ** **
>
> ** **
>
> On Tue, Nov 6, 2012 at 6:38 PM, Kevin Burton <rkevinburton@charter.net
> >wrote:****
>
> ** **
>
> >** **
>
> > So how do I run the view? The purpose of this view is to get a list of *
> ***
>
> > SKUs for all documents so I don't need to filter.****
>
> >** **
>
> > -----Original Message-----****
>
> > From: Mark Hahn [mailto:mark@hahnca.com <ma...@hahnca.com>]****
>
> > Sent: Tuesday, November 06, 2012 8:25 PM****
>
> > To: user@couchdb.apache.org****
>
> > Subject: Re: Get all documents of a certain type.****
>
> >** **
>
> > You can run the view, but it shows all docs in that view.  You can't ***
> *
>
> > filter the results with keys.****
>
> >** **
>
> > On Tue, Nov 6, 2012 at 6:22 PM, Kevin Burton****
>
> > <rk...@charter.net>wrote:****
>
> >** **
>
> > > What does it mean that Futon can't do keys? I cannot run this view ***
> *
>
> > > in Futon?****
>
> > >****
>
> > > -----Original Message-----****
>
> > > From: Mark Hahn [mailto:mark@hahnca.com <ma...@hahnca.com>]****
>
> > > Sent: Tuesday, November 06, 2012 8:19 PM****
>
> > > To: user@couchdb.apache.org****
>
> > > Subject: Re: Get all documents of a certain type.****
>
> > >****
>
> > > I meant futon *can't* do keys****
>
> > >****
>
> > >****
>
> > > On Tue, Nov 6, 2012 at 6:18 PM, Mark Hahn <ma...@hahnca.com> wrote:****
>
> > >****
>
> > > > Futon can do keys****
>
> > > >****
>
> > > > On Tue, Nov 6, 2012 at 6:16 PM, Kevin Burton****
>
> > > <rk...@charter.net>wrote:****
>
> > > >****
>
> > > >> I am getting there. My mapper looks like:****
>
> > > >>****
>
> > > >>****
>
> > > >>****
>
> > > >> function(doc) {****
>
> > > >>****
>
> > > >>     if(doc._id.indexOf('product-') == 0 {****
>
> > > >>****
>
> > > >>         emit([doc.SKU], null);****
>
> > > >>****
>
> > > >>     }****
>
> > > >>****
>
> > > >> }****
>
> > > >>****
>
> > > >>****
>
> > > >>****
>
> > > >> With a key of 'by-sku'. How do I run this in Futon? In his case ***
> *
>
> > > >> does doc.type do the same thing as indexOf?****
>
> > > >>****
>
> > > >>****
>
> > > >>****
>
> > > >> -----Original Message-----****
>
> > > >> From: Dustin Sallings [mailto:dustin@spy.net <du...@spy.net>]****
>
> > > >> Sent: Tuesday, November 06, 2012 7:03 PM****
>
> > > >> To: user@couchdb.apache.org****
>
> > > >> Subject: Re: Get all documents of a certain type.****
>
> > > >>****
>
> > > >>****
>
> > > >>****
>
> > > >> "Kevin Burton" < <ma...@charter.net>>
> ****
>
> > > >> rkevinburton@charter.net>****
>
> > > >>****
>
> > > >> writes:****
>
> > > >>****
>
> > > >>****
>
> > > >>****
>
> > > >> > I thought the "or" you were referring to was the "or" that I ****
>
> > > >> > said were****
>
> > > >>****
>
> > > >> > the types of documents "product-xxx" or "order-xxx".****
>
> > > >>****
>
> > > >> >****
>
> > > >>****
>
> > > >> > If I have a view what would be the request and what would the ***
> *
>
> > > >> > view****
>
> > > >>****
>
> > > >> > look like? If I didn't have a view what would the query look like?
> ****
>
> > > >> > So****
>
> > > >>****
>
> > > >> > two questions.****
>
> > > >>****
>
> > > >>****
>
> > > >>****
>
> > > >>   The second was answered earlier.  It's the _all_docs query.****
>
> > > >>****
>
> > > >>****
>
> > > >>****
>
> > > >>   The first would be a little be easier to answer if you could ****
>
> > > >> provide an example document, but you'll have a mapper that looked *
> ***
>
> > > >> something like****
>
> > > >>****
>
> > > >> this:****
>
> > > >>****
>
> > > >>****
>
> > > >>****
>
> > > >>       function(doc) {****
>
> > > >>****
>
> > > >>         if (doc.type === 'product') {****
>
> > > >>****
>
> > > >>             emit(doc.sku, null);****
>
> > > >>****
>
> > > >>         }****
>
> > > >>****
>
> > > >>       }****
>
> > > >>****
>
> > > >>****
>
> > > >>****
>
> > > >>   You would then save that as a design document and query query it.
> ****
>
> > > >> If you do this from futon, you can experiment interactively, and **
> **
>
> > > >> the click on the little raw result tab thing in the top to get ****
>
> > > >> the URL you'd use from your application.****
>
> > > >>****
>
> > > >>****
>
> > > >>****
>
> > > >> --****
>
> > > >>****
>
> > > >> dustin****
>
> > > >>****
>
> > > >>****
>
> > > >>****
>
> > > >>****
>
> > > >****
>
> > >****
>
> > >****
>
> >** **
>
> >** **
>

RE: Get all documents of a certain type.

Posted by Kevin Burton <rk...@charter.net>.
I don't see this drop-down.

 



 

-----Original Message-----
From: Mark Hahn [mailto:mark@hahnca.com] 
Sent: Tuesday, November 06, 2012 9:00 PM
To: user@couchdb.apache.org
Subject: Re: Get all documents of a certain type.

 

> So how do I run the view?

 

Choose it from the drop-down list of views.

 

 

On Tue, Nov 6, 2012 at 6:38 PM, Kevin Burton <
<ma...@charter.net> rkevinburton@charter.net>wrote:

 

> 

> So how do I run the view? The purpose of this view is to get a list of 

> SKUs for all documents so I don't need to filter.

> 

> -----Original Message-----

> From: Mark Hahn [ <ma...@hahnca.com> mailto:mark@hahnca.com]

> Sent: Tuesday, November 06, 2012 8:25 PM

> To:  <ma...@couchdb.apache.org> user@couchdb.apache.org

> Subject: Re: Get all documents of a certain type.

> 

> You can run the view, but it shows all docs in that view.  You can't 

> filter the results with keys.

> 

> On Tue, Nov 6, 2012 at 6:22 PM, Kevin Burton

> < <ma...@charter.net> rkevinburton@charter.net>wrote:

> 

> > What does it mean that Futon can't do keys? I cannot run this view 

> > in Futon?

> >

> > -----Original Message-----

> > From: Mark Hahn [ <ma...@hahnca.com> mailto:mark@hahnca.com]

> > Sent: Tuesday, November 06, 2012 8:19 PM

> > To:  <ma...@couchdb.apache.org> user@couchdb.apache.org

> > Subject: Re: Get all documents of a certain type.

> >

> > I meant futon *can't* do keys

> >

> >

> > On Tue, Nov 6, 2012 at 6:18 PM, Mark Hahn < <ma...@hahnca.com>
mark@hahnca.com> wrote:

> >

> > > Futon can do keys

> > >

> > > On Tue, Nov 6, 2012 at 6:16 PM, Kevin Burton

> > < <ma...@charter.net> rkevinburton@charter.net>wrote:

> > >

> > >> I am getting there. My mapper looks like:

> > >>

> > >>

> > >>

> > >> function(doc) {

> > >>

> > >>     if(doc._id.indexOf('product-') == 0 {

> > >>

> > >>         emit([doc.SKU], null);

> > >>

> > >>     }

> > >>

> > >> }

> > >>

> > >>

> > >>

> > >> With a key of 'by-sku'. How do I run this in Futon? In his case 

> > >> does doc.type do the same thing as indexOf?

> > >>

> > >>

> > >>

> > >> -----Original Message-----

> > >> From: Dustin Sallings [ <ma...@spy.net>
mailto:dustin@spy.net]

> > >> Sent: Tuesday, November 06, 2012 7:03 PM

> > >> To:  <ma...@couchdb.apache.org> user@couchdb.apache.org

> > >> Subject: Re: Get all documents of a certain type.

> > >>

> > >>

> > >>

> > >> "Kevin Burton" < < <ma...@charter.net>
mailto:rkevinburton@charter.net> 

> > >>  <ma...@charter.net> rkevinburton@charter.net>

> > >>

> > >> writes:

> > >>

> > >>

> > >>

> > >> > I thought the "or" you were referring to was the "or" that I 

> > >> > said were

> > >>

> > >> > the types of documents "product-xxx" or "order-xxx".

> > >>

> > >> >

> > >>

> > >> > If I have a view what would be the request and what would the 

> > >> > view

> > >>

> > >> > look like? If I didn't have a view what would the query look like?

> > >> > So

> > >>

> > >> > two questions.

> > >>

> > >>

> > >>

> > >>   The second was answered earlier.  It's the _all_docs query.

> > >>

> > >>

> > >>

> > >>   The first would be a little be easier to answer if you could 

> > >> provide an example document, but you'll have a mapper that looked 

> > >> something like

> > >>

> > >> this:

> > >>

> > >>

> > >>

> > >>       function(doc) {

> > >>

> > >>         if (doc.type === 'product') {

> > >>

> > >>             emit(doc.sku, null);

> > >>

> > >>         }

> > >>

> > >>       }

> > >>

> > >>

> > >>

> > >>   You would then save that as a design document and query query it.

> > >> If you do this from futon, you can experiment interactively, and 

> > >> the click on the little raw result tab thing in the top to get 

> > >> the URL you'd use from your application.

> > >>

> > >>

> > >>

> > >> --

> > >>

> > >> dustin

> > >>

> > >>

> > >>

> > >>

> > >

> >

> >

> 

> 


Re: Get all documents of a certain type.

Posted by Mark Hahn <ma...@hahnca.com>.
> So how do I run the view?

Choose it from the drop-down list of views.


On Tue, Nov 6, 2012 at 6:38 PM, Kevin Burton <rk...@charter.net>wrote:

>
> So how do I run the view? The purpose of this view is to get a list of SKUs
> for all documents so I don't need to filter.
>
> -----Original Message-----
> From: Mark Hahn [mailto:mark@hahnca.com]
> Sent: Tuesday, November 06, 2012 8:25 PM
> To: user@couchdb.apache.org
> Subject: Re: Get all documents of a certain type.
>
> You can run the view, but it shows all docs in that view.  You can't filter
> the results with keys.
>
> On Tue, Nov 6, 2012 at 6:22 PM, Kevin Burton
> <rk...@charter.net>wrote:
>
> > What does it mean that Futon can't do keys? I cannot run this view in
> > Futon?
> >
> > -----Original Message-----
> > From: Mark Hahn [mailto:mark@hahnca.com]
> > Sent: Tuesday, November 06, 2012 8:19 PM
> > To: user@couchdb.apache.org
> > Subject: Re: Get all documents of a certain type.
> >
> > I meant futon *can't* do keys
> >
> >
> > On Tue, Nov 6, 2012 at 6:18 PM, Mark Hahn <ma...@hahnca.com> wrote:
> >
> > > Futon can do keys
> > >
> > > On Tue, Nov 6, 2012 at 6:16 PM, Kevin Burton
> > <rk...@charter.net>wrote:
> > >
> > >> I am getting there. My mapper looks like:
> > >>
> > >>
> > >>
> > >> function(doc) {
> > >>
> > >>     if(doc._id.indexOf('product-') == 0 {
> > >>
> > >>         emit([doc.SKU], null);
> > >>
> > >>     }
> > >>
> > >> }
> > >>
> > >>
> > >>
> > >> With a key of 'by-sku'. How do I run this in Futon? In his case
> > >> does doc.type do the same thing as indexOf?
> > >>
> > >>
> > >>
> > >> -----Original Message-----
> > >> From: Dustin Sallings [mailto:dustin@spy.net]
> > >> Sent: Tuesday, November 06, 2012 7:03 PM
> > >> To: user@couchdb.apache.org
> > >> Subject: Re: Get all documents of a certain type.
> > >>
> > >>
> > >>
> > >> "Kevin Burton" < <ma...@charter.net>
> > >> rkevinburton@charter.net>
> > >>
> > >> writes:
> > >>
> > >>
> > >>
> > >> > I thought the "or" you were referring to was the "or" that I said
> > >> > were
> > >>
> > >> > the types of documents "product-xxx" or "order-xxx".
> > >>
> > >> >
> > >>
> > >> > If I have a view what would be the request and what would the
> > >> > view
> > >>
> > >> > look like? If I didn't have a view what would the query look like?
> > >> > So
> > >>
> > >> > two questions.
> > >>
> > >>
> > >>
> > >>   The second was answered earlier.  It's the _all_docs query.
> > >>
> > >>
> > >>
> > >>   The first would be a little be easier to answer if you could
> > >> provide an example document, but you'll have a mapper that looked
> > >> something like
> > >>
> > >> this:
> > >>
> > >>
> > >>
> > >>       function(doc) {
> > >>
> > >>         if (doc.type === 'product') {
> > >>
> > >>             emit(doc.sku, null);
> > >>
> > >>         }
> > >>
> > >>       }
> > >>
> > >>
> > >>
> > >>   You would then save that as a design document and query query it.
> > >> If you do this from futon, you can experiment interactively, and
> > >> the click on the little raw result tab thing in the top to get the
> > >> URL you'd use from your application.
> > >>
> > >>
> > >>
> > >> --
> > >>
> > >> dustin
> > >>
> > >>
> > >>
> > >>
> > >
> >
> >
>
>

RE: Get all documents of a certain type.

Posted by Kevin Burton <rk...@charter.net>.
So how do I run the view? The purpose of this view is to get a list of SKUs
for all documents so I don't need to filter.

-----Original Message-----
From: Mark Hahn [mailto:mark@hahnca.com] 
Sent: Tuesday, November 06, 2012 8:25 PM
To: user@couchdb.apache.org
Subject: Re: Get all documents of a certain type.

You can run the view, but it shows all docs in that view.  You can't filter
the results with keys.

On Tue, Nov 6, 2012 at 6:22 PM, Kevin Burton
<rk...@charter.net>wrote:

> What does it mean that Futon can't do keys? I cannot run this view in 
> Futon?
>
> -----Original Message-----
> From: Mark Hahn [mailto:mark@hahnca.com]
> Sent: Tuesday, November 06, 2012 8:19 PM
> To: user@couchdb.apache.org
> Subject: Re: Get all documents of a certain type.
>
> I meant futon *can't* do keys
>
>
> On Tue, Nov 6, 2012 at 6:18 PM, Mark Hahn <ma...@hahnca.com> wrote:
>
> > Futon can do keys
> >
> > On Tue, Nov 6, 2012 at 6:16 PM, Kevin Burton
> <rk...@charter.net>wrote:
> >
> >> I am getting there. My mapper looks like:
> >>
> >>
> >>
> >> function(doc) {
> >>
> >>     if(doc._id.indexOf('product-') == 0 {
> >>
> >>         emit([doc.SKU], null);
> >>
> >>     }
> >>
> >> }
> >>
> >>
> >>
> >> With a key of 'by-sku'. How do I run this in Futon? In his case 
> >> does doc.type do the same thing as indexOf?
> >>
> >>
> >>
> >> -----Original Message-----
> >> From: Dustin Sallings [mailto:dustin@spy.net]
> >> Sent: Tuesday, November 06, 2012 7:03 PM
> >> To: user@couchdb.apache.org
> >> Subject: Re: Get all documents of a certain type.
> >>
> >>
> >>
> >> "Kevin Burton" < <ma...@charter.net> 
> >> rkevinburton@charter.net>
> >>
> >> writes:
> >>
> >>
> >>
> >> > I thought the "or" you were referring to was the "or" that I said 
> >> > were
> >>
> >> > the types of documents "product-xxx" or "order-xxx".
> >>
> >> >
> >>
> >> > If I have a view what would be the request and what would the 
> >> > view
> >>
> >> > look like? If I didn't have a view what would the query look like?
> >> > So
> >>
> >> > two questions.
> >>
> >>
> >>
> >>   The second was answered earlier.  It's the _all_docs query.
> >>
> >>
> >>
> >>   The first would be a little be easier to answer if you could 
> >> provide an example document, but you'll have a mapper that looked 
> >> something like
> >>
> >> this:
> >>
> >>
> >>
> >>       function(doc) {
> >>
> >>         if (doc.type === 'product') {
> >>
> >>             emit(doc.sku, null);
> >>
> >>         }
> >>
> >>       }
> >>
> >>
> >>
> >>   You would then save that as a design document and query query it.
> >> If you do this from futon, you can experiment interactively, and 
> >> the click on the little raw result tab thing in the top to get the 
> >> URL you'd use from your application.
> >>
> >>
> >>
> >> --
> >>
> >> dustin
> >>
> >>
> >>
> >>
> >
>
>


RE: Get all documents of a certain type.

Posted by Benoit Chesneau <bc...@gmail.com>.
Oups..  it's http://github.com/refuge/rcouch there are some details in the
refuge.io blog
On Nov 7, 2012 3:40 AM, "Kevin Burton" <rk...@charter.net> wrote:

> This URL gives me a 404 error.
>
> -----Original Message-----
> From: Benoit Chesneau [mailto:bchesneau@gmail.com]
> Sent: Tuesday, November 06, 2012 8:27 PM
> To: user@couchdb.apache.org
> Subject: Re: Get all documents of a certain type.
>
> It's possible in rcouch (http://github.com/benoitc/rcouch) . I'm
> extracting
> patches from it this week so hopefully it will be in couchdb as well.
>
> On Wed, Nov 7, 2012 at 3:25 AM, Mark Hahn <ma...@hahnca.com> wrote:
> > You can run the view, but it shows all docs in that view.  You can't
> > filter the results with keys.
> >
> > On Tue, Nov 6, 2012 at 6:22 PM, Kevin Burton
> <rk...@charter.net>wrote:
> >
> >> What does it mean that Futon can't do keys? I cannot run this view in
> >> Futon?
> >>
> >> -----Original Message-----
> >> From: Mark Hahn [mailto:mark@hahnca.com]
> >> Sent: Tuesday, November 06, 2012 8:19 PM
> >> To: user@couchdb.apache.org
> >> Subject: Re: Get all documents of a certain type.
> >>
> >> I meant futon *can't* do keys
> >>
> >>
> >> On Tue, Nov 6, 2012 at 6:18 PM, Mark Hahn <ma...@hahnca.com> wrote:
> >>
> >> > Futon can do keys
> >> >
> >> > On Tue, Nov 6, 2012 at 6:16 PM, Kevin Burton
> >> <rk...@charter.net>wrote:
> >> >
> >> >> I am getting there. My mapper looks like:
> >> >>
> >> >>
> >> >>
> >> >> function(doc) {
> >> >>
> >> >>     if(doc._id.indexOf('product-') == 0 {
> >> >>
> >> >>         emit([doc.SKU], null);
> >> >>
> >> >>     }
> >> >>
> >> >> }
> >> >>
> >> >>
> >> >>
> >> >> With a key of 'by-sku'. How do I run this in Futon? In his case
> >> >> does doc.type do the same thing as indexOf?
> >> >>
> >> >>
> >> >>
> >> >> -----Original Message-----
> >> >> From: Dustin Sallings [mailto:dustin@spy.net]
> >> >> Sent: Tuesday, November 06, 2012 7:03 PM
> >> >> To: user@couchdb.apache.org
> >> >> Subject: Re: Get all documents of a certain type.
> >> >>
> >> >>
> >> >>
> >> >> "Kevin Burton" < <ma...@charter.net>
> >> >> rkevinburton@charter.net>
> >> >>
> >> >> writes:
> >> >>
> >> >>
> >> >>
> >> >> > I thought the "or" you were referring to was the "or" that I
> >> >> > said were
> >> >>
> >> >> > the types of documents "product-xxx" or "order-xxx".
> >> >>
> >> >> >
> >> >>
> >> >> > If I have a view what would be the request and what would the
> >> >> > view
> >> >>
> >> >> > look like? If I didn't have a view what would the query look like?
> >> >> > So
> >> >>
> >> >> > two questions.
> >> >>
> >> >>
> >> >>
> >> >>   The second was answered earlier.  It's the _all_docs query.
> >> >>
> >> >>
> >> >>
> >> >>   The first would be a little be easier to answer if you could
> >> >> provide an example document, but you'll have a mapper that looked
> >> >> something like
> >> >>
> >> >> this:
> >> >>
> >> >>
> >> >>
> >> >>       function(doc) {
> >> >>
> >> >>         if (doc.type === 'product') {
> >> >>
> >> >>             emit(doc.sku, null);
> >> >>
> >> >>         }
> >> >>
> >> >>       }
> >> >>
> >> >>
> >> >>
> >> >>   You would then save that as a design document and query query it.
> >> >> If you do this from futon, you can experiment interactively, and
> >> >> the click on the little raw result tab thing in the top to get the
> >> >> URL you'd use from your application.
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >>
> >> >> dustin
> >> >>
> >> >>
> >> >>
> >> >>
> >> >
> >>
> >>
>
>

RE: Get all documents of a certain type.

Posted by Kevin Burton <rk...@charter.net>.
This URL gives me a 404 error.

-----Original Message-----
From: Benoit Chesneau [mailto:bchesneau@gmail.com] 
Sent: Tuesday, November 06, 2012 8:27 PM
To: user@couchdb.apache.org
Subject: Re: Get all documents of a certain type.

It's possible in rcouch (http://github.com/benoitc/rcouch) . I'm extracting
patches from it this week so hopefully it will be in couchdb as well.

On Wed, Nov 7, 2012 at 3:25 AM, Mark Hahn <ma...@hahnca.com> wrote:
> You can run the view, but it shows all docs in that view.  You can't 
> filter the results with keys.
>
> On Tue, Nov 6, 2012 at 6:22 PM, Kevin Burton
<rk...@charter.net>wrote:
>
>> What does it mean that Futon can't do keys? I cannot run this view in 
>> Futon?
>>
>> -----Original Message-----
>> From: Mark Hahn [mailto:mark@hahnca.com]
>> Sent: Tuesday, November 06, 2012 8:19 PM
>> To: user@couchdb.apache.org
>> Subject: Re: Get all documents of a certain type.
>>
>> I meant futon *can't* do keys
>>
>>
>> On Tue, Nov 6, 2012 at 6:18 PM, Mark Hahn <ma...@hahnca.com> wrote:
>>
>> > Futon can do keys
>> >
>> > On Tue, Nov 6, 2012 at 6:16 PM, Kevin Burton
>> <rk...@charter.net>wrote:
>> >
>> >> I am getting there. My mapper looks like:
>> >>
>> >>
>> >>
>> >> function(doc) {
>> >>
>> >>     if(doc._id.indexOf('product-') == 0 {
>> >>
>> >>         emit([doc.SKU], null);
>> >>
>> >>     }
>> >>
>> >> }
>> >>
>> >>
>> >>
>> >> With a key of 'by-sku'. How do I run this in Futon? In his case 
>> >> does doc.type do the same thing as indexOf?
>> >>
>> >>
>> >>
>> >> -----Original Message-----
>> >> From: Dustin Sallings [mailto:dustin@spy.net]
>> >> Sent: Tuesday, November 06, 2012 7:03 PM
>> >> To: user@couchdb.apache.org
>> >> Subject: Re: Get all documents of a certain type.
>> >>
>> >>
>> >>
>> >> "Kevin Burton" < <ma...@charter.net> 
>> >> rkevinburton@charter.net>
>> >>
>> >> writes:
>> >>
>> >>
>> >>
>> >> > I thought the "or" you were referring to was the "or" that I 
>> >> > said were
>> >>
>> >> > the types of documents "product-xxx" or "order-xxx".
>> >>
>> >> >
>> >>
>> >> > If I have a view what would be the request and what would the 
>> >> > view
>> >>
>> >> > look like? If I didn't have a view what would the query look like?
>> >> > So
>> >>
>> >> > two questions.
>> >>
>> >>
>> >>
>> >>   The second was answered earlier.  It's the _all_docs query.
>> >>
>> >>
>> >>
>> >>   The first would be a little be easier to answer if you could 
>> >> provide an example document, but you'll have a mapper that looked 
>> >> something like
>> >>
>> >> this:
>> >>
>> >>
>> >>
>> >>       function(doc) {
>> >>
>> >>         if (doc.type === 'product') {
>> >>
>> >>             emit(doc.sku, null);
>> >>
>> >>         }
>> >>
>> >>       }
>> >>
>> >>
>> >>
>> >>   You would then save that as a design document and query query it.
>> >> If you do this from futon, you can experiment interactively, and 
>> >> the click on the little raw result tab thing in the top to get the 
>> >> URL you'd use from your application.
>> >>
>> >>
>> >>
>> >> --
>> >>
>> >> dustin
>> >>
>> >>
>> >>
>> >>
>> >
>>
>>


Re: Get all documents of a certain type.

Posted by Benoit Chesneau <bc...@gmail.com>.
It's possible in rcouch (http://github.com/benoitc/rcouch) . I'm
extracting patches from it this week so hopefully it will be in
couchdb as well.

On Wed, Nov 7, 2012 at 3:25 AM, Mark Hahn <ma...@hahnca.com> wrote:
> You can run the view, but it shows all docs in that view.  You can't filter
> the results with keys.
>
> On Tue, Nov 6, 2012 at 6:22 PM, Kevin Burton <rk...@charter.net>wrote:
>
>> What does it mean that Futon can't do keys? I cannot run this view in
>> Futon?
>>
>> -----Original Message-----
>> From: Mark Hahn [mailto:mark@hahnca.com]
>> Sent: Tuesday, November 06, 2012 8:19 PM
>> To: user@couchdb.apache.org
>> Subject: Re: Get all documents of a certain type.
>>
>> I meant futon *can't* do keys
>>
>>
>> On Tue, Nov 6, 2012 at 6:18 PM, Mark Hahn <ma...@hahnca.com> wrote:
>>
>> > Futon can do keys
>> >
>> > On Tue, Nov 6, 2012 at 6:16 PM, Kevin Burton
>> <rk...@charter.net>wrote:
>> >
>> >> I am getting there. My mapper looks like:
>> >>
>> >>
>> >>
>> >> function(doc) {
>> >>
>> >>     if(doc._id.indexOf('product-') == 0 {
>> >>
>> >>         emit([doc.SKU], null);
>> >>
>> >>     }
>> >>
>> >> }
>> >>
>> >>
>> >>
>> >> With a key of 'by-sku'. How do I run this in Futon? In his case does
>> >> doc.type do the same thing as indexOf?
>> >>
>> >>
>> >>
>> >> -----Original Message-----
>> >> From: Dustin Sallings [mailto:dustin@spy.net]
>> >> Sent: Tuesday, November 06, 2012 7:03 PM
>> >> To: user@couchdb.apache.org
>> >> Subject: Re: Get all documents of a certain type.
>> >>
>> >>
>> >>
>> >> "Kevin Burton" < <ma...@charter.net>
>> >> rkevinburton@charter.net>
>> >>
>> >> writes:
>> >>
>> >>
>> >>
>> >> > I thought the "or" you were referring to was the "or" that I said
>> >> > were
>> >>
>> >> > the types of documents "product-xxx" or "order-xxx".
>> >>
>> >> >
>> >>
>> >> > If I have a view what would be the request and what would the view
>> >>
>> >> > look like? If I didn't have a view what would the query look like?
>> >> > So
>> >>
>> >> > two questions.
>> >>
>> >>
>> >>
>> >>   The second was answered earlier.  It's the _all_docs query.
>> >>
>> >>
>> >>
>> >>   The first would be a little be easier to answer if you could
>> >> provide an example document, but you'll have a mapper that looked
>> >> something like
>> >>
>> >> this:
>> >>
>> >>
>> >>
>> >>       function(doc) {
>> >>
>> >>         if (doc.type === 'product') {
>> >>
>> >>             emit(doc.sku, null);
>> >>
>> >>         }
>> >>
>> >>       }
>> >>
>> >>
>> >>
>> >>   You would then save that as a design document and query query it.
>> >> If you do this from futon, you can experiment interactively, and the
>> >> click on the little raw result tab thing in the top to get the URL
>> >> you'd use from your application.
>> >>
>> >>
>> >>
>> >> --
>> >>
>> >> dustin
>> >>
>> >>
>> >>
>> >>
>> >
>>
>>

Re: Get all documents of a certain type.

Posted by Mark Hahn <ma...@hahnca.com>.
You can run the view, but it shows all docs in that view.  You can't filter
the results with keys.

On Tue, Nov 6, 2012 at 6:22 PM, Kevin Burton <rk...@charter.net>wrote:

> What does it mean that Futon can't do keys? I cannot run this view in
> Futon?
>
> -----Original Message-----
> From: Mark Hahn [mailto:mark@hahnca.com]
> Sent: Tuesday, November 06, 2012 8:19 PM
> To: user@couchdb.apache.org
> Subject: Re: Get all documents of a certain type.
>
> I meant futon *can't* do keys
>
>
> On Tue, Nov 6, 2012 at 6:18 PM, Mark Hahn <ma...@hahnca.com> wrote:
>
> > Futon can do keys
> >
> > On Tue, Nov 6, 2012 at 6:16 PM, Kevin Burton
> <rk...@charter.net>wrote:
> >
> >> I am getting there. My mapper looks like:
> >>
> >>
> >>
> >> function(doc) {
> >>
> >>     if(doc._id.indexOf('product-') == 0 {
> >>
> >>         emit([doc.SKU], null);
> >>
> >>     }
> >>
> >> }
> >>
> >>
> >>
> >> With a key of 'by-sku'. How do I run this in Futon? In his case does
> >> doc.type do the same thing as indexOf?
> >>
> >>
> >>
> >> -----Original Message-----
> >> From: Dustin Sallings [mailto:dustin@spy.net]
> >> Sent: Tuesday, November 06, 2012 7:03 PM
> >> To: user@couchdb.apache.org
> >> Subject: Re: Get all documents of a certain type.
> >>
> >>
> >>
> >> "Kevin Burton" < <ma...@charter.net>
> >> rkevinburton@charter.net>
> >>
> >> writes:
> >>
> >>
> >>
> >> > I thought the "or" you were referring to was the "or" that I said
> >> > were
> >>
> >> > the types of documents "product-xxx" or "order-xxx".
> >>
> >> >
> >>
> >> > If I have a view what would be the request and what would the view
> >>
> >> > look like? If I didn't have a view what would the query look like?
> >> > So
> >>
> >> > two questions.
> >>
> >>
> >>
> >>   The second was answered earlier.  It's the _all_docs query.
> >>
> >>
> >>
> >>   The first would be a little be easier to answer if you could
> >> provide an example document, but you'll have a mapper that looked
> >> something like
> >>
> >> this:
> >>
> >>
> >>
> >>       function(doc) {
> >>
> >>         if (doc.type === 'product') {
> >>
> >>             emit(doc.sku, null);
> >>
> >>         }
> >>
> >>       }
> >>
> >>
> >>
> >>   You would then save that as a design document and query query it.
> >> If you do this from futon, you can experiment interactively, and the
> >> click on the little raw result tab thing in the top to get the URL
> >> you'd use from your application.
> >>
> >>
> >>
> >> --
> >>
> >> dustin
> >>
> >>
> >>
> >>
> >
>
>

Re: Get all documents of a certain type.

Posted by Dustin Sallings <du...@spy.net>.
"Kevin Burton" <rk...@charter.net>
writes:

> What does it mean that Futon can't do keys? I cannot run this view in Futon?

  You can, but not in a way that's useful enough to you.  If you defined
the view in futon, it should've run it right there where you wrote it.

  However, you won't be able to pass a "key" parameter in.  Given your
view definition, this shouldn't matter, however.

-- 
dustin


RE: Get all documents of a certain type.

Posted by Kevin Burton <rk...@charter.net>.
What does it mean that Futon can't do keys? I cannot run this view in Futon?

-----Original Message-----
From: Mark Hahn [mailto:mark@hahnca.com] 
Sent: Tuesday, November 06, 2012 8:19 PM
To: user@couchdb.apache.org
Subject: Re: Get all documents of a certain type.

I meant futon *can't* do keys


On Tue, Nov 6, 2012 at 6:18 PM, Mark Hahn <ma...@hahnca.com> wrote:

> Futon can do keys
>
> On Tue, Nov 6, 2012 at 6:16 PM, Kevin Burton
<rk...@charter.net>wrote:
>
>> I am getting there. My mapper looks like:
>>
>>
>>
>> function(doc) {
>>
>>     if(doc._id.indexOf('product-') == 0 {
>>
>>         emit([doc.SKU], null);
>>
>>     }
>>
>> }
>>
>>
>>
>> With a key of 'by-sku'. How do I run this in Futon? In his case does 
>> doc.type do the same thing as indexOf?
>>
>>
>>
>> -----Original Message-----
>> From: Dustin Sallings [mailto:dustin@spy.net]
>> Sent: Tuesday, November 06, 2012 7:03 PM
>> To: user@couchdb.apache.org
>> Subject: Re: Get all documents of a certain type.
>>
>>
>>
>> "Kevin Burton" < <ma...@charter.net> 
>> rkevinburton@charter.net>
>>
>> writes:
>>
>>
>>
>> > I thought the "or" you were referring to was the "or" that I said 
>> > were
>>
>> > the types of documents "product-xxx" or "order-xxx".
>>
>> >
>>
>> > If I have a view what would be the request and what would the view
>>
>> > look like? If I didn't have a view what would the query look like? 
>> > So
>>
>> > two questions.
>>
>>
>>
>>   The second was answered earlier.  It's the _all_docs query.
>>
>>
>>
>>   The first would be a little be easier to answer if you could 
>> provide an example document, but you'll have a mapper that looked 
>> something like
>>
>> this:
>>
>>
>>
>>       function(doc) {
>>
>>         if (doc.type === 'product') {
>>
>>             emit(doc.sku, null);
>>
>>         }
>>
>>       }
>>
>>
>>
>>   You would then save that as a design document and query query it.  
>> If you do this from futon, you can experiment interactively, and the 
>> click on the little raw result tab thing in the top to get the URL 
>> you'd use from your application.
>>
>>
>>
>> --
>>
>> dustin
>>
>>
>>
>>
>


Re: Get all documents of a certain type.

Posted by Mark Hahn <ma...@hahnca.com>.
I meant futon *can't* do keys


On Tue, Nov 6, 2012 at 6:18 PM, Mark Hahn <ma...@hahnca.com> wrote:

> Futon can do keys
>
> On Tue, Nov 6, 2012 at 6:16 PM, Kevin Burton <rk...@charter.net>wrote:
>
>> I am getting there. My mapper looks like:
>>
>>
>>
>> function(doc) {
>>
>>     if(doc._id.indexOf('product-') == 0 {
>>
>>         emit([doc.SKU], null);
>>
>>     }
>>
>> }
>>
>>
>>
>> With a key of 'by-sku'. How do I run this in Futon? In his case does
>> doc.type do the same thing as indexOf?
>>
>>
>>
>> -----Original Message-----
>> From: Dustin Sallings [mailto:dustin@spy.net]
>> Sent: Tuesday, November 06, 2012 7:03 PM
>> To: user@couchdb.apache.org
>> Subject: Re: Get all documents of a certain type.
>>
>>
>>
>> "Kevin Burton" < <ma...@charter.net>
>> rkevinburton@charter.net>
>>
>> writes:
>>
>>
>>
>> > I thought the "or" you were referring to was the "or" that I said were
>>
>> > the types of documents "product-xxx" or "order-xxx".
>>
>> >
>>
>> > If I have a view what would be the request and what would the view
>>
>> > look like? If I didn't have a view what would the query look like? So
>>
>> > two questions.
>>
>>
>>
>>   The second was answered earlier.  It's the _all_docs query.
>>
>>
>>
>>   The first would be a little be easier to answer if you could provide an
>> example document, but you'll have a mapper that looked something like
>>
>> this:
>>
>>
>>
>>       function(doc) {
>>
>>         if (doc.type === 'product') {
>>
>>             emit(doc.sku, null);
>>
>>         }
>>
>>       }
>>
>>
>>
>>   You would then save that as a design document and query query it.  If
>> you
>> do this from futon, you can experiment interactively, and the click on the
>> little raw result tab thing in the top to get the URL you'd use from your
>> application.
>>
>>
>>
>> --
>>
>> dustin
>>
>>
>>
>>
>

Re: Get all documents of a certain type.

Posted by Mark Hahn <ma...@hahnca.com>.
Futon can do keys

On Tue, Nov 6, 2012 at 6:16 PM, Kevin Burton <rk...@charter.net>wrote:

> I am getting there. My mapper looks like:
>
>
>
> function(doc) {
>
>     if(doc._id.indexOf('product-') == 0 {
>
>         emit([doc.SKU], null);
>
>     }
>
> }
>
>
>
> With a key of 'by-sku'. How do I run this in Futon? In his case does
> doc.type do the same thing as indexOf?
>
>
>
> -----Original Message-----
> From: Dustin Sallings [mailto:dustin@spy.net]
> Sent: Tuesday, November 06, 2012 7:03 PM
> To: user@couchdb.apache.org
> Subject: Re: Get all documents of a certain type.
>
>
>
> "Kevin Burton" < <ma...@charter.net>
> rkevinburton@charter.net>
>
> writes:
>
>
>
> > I thought the "or" you were referring to was the "or" that I said were
>
> > the types of documents "product-xxx" or "order-xxx".
>
> >
>
> > If I have a view what would be the request and what would the view
>
> > look like? If I didn't have a view what would the query look like? So
>
> > two questions.
>
>
>
>   The second was answered earlier.  It's the _all_docs query.
>
>
>
>   The first would be a little be easier to answer if you could provide an
> example document, but you'll have a mapper that looked something like
>
> this:
>
>
>
>       function(doc) {
>
>         if (doc.type === 'product') {
>
>             emit(doc.sku, null);
>
>         }
>
>       }
>
>
>
>   You would then save that as a design document and query query it.  If you
> do this from futon, you can experiment interactively, and the click on the
> little raw result tab thing in the top to get the URL you'd use from your
> application.
>
>
>
> --
>
> dustin
>
>
>
>

RE: Get all documents of a certain type.

Posted by Kevin Burton <rk...@charter.net>.
I am getting there. My mapper looks like:

 

function(doc) {

    if(doc._id.indexOf('product-') == 0 {

        emit([doc.SKU], null);

    }

}

 

With a key of 'by-sku'. How do I run this in Futon? In his case does
doc.type do the same thing as indexOf?

 

-----Original Message-----
From: Dustin Sallings [mailto:dustin@spy.net] 
Sent: Tuesday, November 06, 2012 7:03 PM
To: user@couchdb.apache.org
Subject: Re: Get all documents of a certain type.

 

"Kevin Burton" < <ma...@charter.net> rkevinburton@charter.net>

writes:

 

> I thought the "or" you were referring to was the "or" that I said were 

> the types of documents "product-xxx" or "order-xxx".

> 

> If I have a view what would be the request and what would the view 

> look like? If I didn't have a view what would the query look like? So 

> two questions.

 

  The second was answered earlier.  It's the _all_docs query.

 

  The first would be a little be easier to answer if you could provide an
example document, but you'll have a mapper that looked something like

this:

 

      function(doc) {

        if (doc.type === 'product') {

            emit(doc.sku, null);

        }

      }

 

  You would then save that as a design document and query query it.  If you
do this from futon, you can experiment interactively, and the click on the
little raw result tab thing in the top to get the URL you'd use from your
application.

 

--

dustin

 


Re: Get all documents of a certain type.

Posted by Dustin Sallings <du...@spy.net>.
"Kevin Burton" <rk...@charter.net>
writes:

> I thought the "or" you were referring to was the "or" that I said were the
> types of documents "product-xxx" or "order-xxx".
>
> If I have a view what would be the request and what would the view look
> like? If I didn't have a view what would the query look like? So two
> questions.

  The second was answered earlier.  It's the _all_docs query.

  The first would be a little be easier to answer if you could provide
an example document, but you'll have a mapper that looked something like
this:

      function(doc) {
        if (doc.type === 'product') {
            emit(doc.sku, null);
        }
      }

  You would then save that as a design document and query query it.  If
you do this from futon, you can experiment interactively, and the click
on the little raw result tab thing in the top to get the URL you'd use
from your application.

-- 
dustin


Re: Get all documents of a certain type.

Posted by Jens Alfke <je...@couchbase.com>.
On Nov 6, 2012, at 4:09 PM, Kevin Burton <rk...@charter.net> wrote:

> If I have a view what would be the request and what would the view look
> like? If I didn't have a view what would the query look like? So two
> questions.

Have you had a chance to read the CouchDB book* online yet? At least the first six chapters? I’m all for helping people out, but as I said before, this thread is currently not a productive use of anyone’s time. We’ve suggested several different resources to you; looking at some of them should be your next step. Until then, I’m not participating any further in this thread.

—Jens

* http://guide.couchdb.org

Re: Get all documents of a certain type.

Posted by ar...@mac.com.
you're right.
sorry for that!
find out where to put my posting.

arthur

Op 7-nov-2012, om 2:01 heeft Dustin Sallings het volgende geschreven:

> arthurs@mac.com writes:
>
>> Got two questions:
>
>   You'll get better answers if you don't hijack threads.
>
> -- 
> dustin
>


Re: Get all documents of a certain type.

Posted by Dustin Sallings <du...@spy.net>.
arthurs@mac.com writes:

> Got two questions:

  You'll get better answers if you don't hijack threads.

-- 
dustin


Re: Get all documents of a certain type.

Posted by ar...@mac.com.
Hi to all,

I'm from The Netherlands, but try this in English.

I do follow the forum of Couchdb for about two years after reading an  
article of Jan Lehnardt of VPRO about it. I more and more get  
interested in using this for websites, but where do I start from?

Got two questions:

1. I guess that Couchdb could be very usefull in developing a job/cv  
website because of the different kinds of documents that are used  
around the jobmarket, e;g. doc, pdf, weblinks, twitterlinks, txt...  
Is this right and more usefull than php/mysql db's?

2. Where is the definite start to learn Couchdb, from first step? Is  
it comparible with php learning, is it a steep learncurve? Which  
skills does one need?

With best regards, Arthur



Op 7-nov-2012, om 1:09 heeft Kevin Burton het volgende geschreven:

> I thought the "or" you were referring to was the "or" that I said  
> were the
> types of documents "product-xxx" or "order-xxx".
>
> If I have a view what would be the request and what would the view  
> look
> like? If I didn't have a view what would the query look like? So two
> questions.
>
> -----Original Message-----
> From: Dustin Sallings [mailto:dustin@spy.net]
> Sent: Tuesday, November 06, 2012 4:46 PM
> To: user@couchdb.apache.org
> Subject: Re: Get all documents of a certain type.
>
> "Kevin Burton" <rk...@charter.net>
> writes:
>
>> I am trying to learn Couch so what doesn't make sense of the "or"?
>
>   Well, as I said in the next sentence.  You can do it with or  
> without a
> view and in either case you can do it in one request.  You asked if  
> you
> needed a view or whether you could do it in one request.  I guess I  
> don't
> understand how you'd form that question.
>
> --
> dustin
>
>


RE: Get all documents of a certain type.

Posted by Kevin Burton <rk...@charter.net>.
I thought the "or" you were referring to was the "or" that I said were the
types of documents "product-xxx" or "order-xxx".

If I have a view what would be the request and what would the view look
like? If I didn't have a view what would the query look like? So two
questions.

-----Original Message-----
From: Dustin Sallings [mailto:dustin@spy.net] 
Sent: Tuesday, November 06, 2012 4:46 PM
To: user@couchdb.apache.org
Subject: Re: Get all documents of a certain type.

"Kevin Burton" <rk...@charter.net>
writes:

> I am trying to learn Couch so what doesn't make sense of the "or"?

  Well, as I said in the next sentence.  You can do it with or without a
view and in either case you can do it in one request.  You asked if you
needed a view or whether you could do it in one request.  I guess I don't
understand how you'd form that question.

--
dustin



Re: Get all documents of a certain type.

Posted by Dustin Sallings <du...@spy.net>.
"Kevin Burton" <rk...@charter.net>
writes:

> I am trying to learn Couch so what doesn't make sense of the "or"?

  Well, as I said in the next sentence.  You can do it with or without a
view and in either case you can do it in one request.  You asked if you
needed a view or whether you could do it in one request.  I guess I
don't understand how you'd form that question.

-- 
dustin


RE: Get all documents of a certain type.

Posted by Kevin Burton <rk...@charter.net>.
I am trying to learn Couch so what doesn't make sense of the "or"?

-----Original Message-----
From: Dustin Sallings [mailto:dustin@spy.net] 
Sent: Tuesday, November 06, 2012 4:11 PM
To: user@couchdb.apache.org
Subject: Re: Get all documents of a certain type.

"Kevin Burton" <rk...@charter.net>
writes:

> In my Couch database I have a mixture of documents. The documents that 
> I am interested in have an Id of 'product-xxxxxxx' or 'order-xxxxxx'. 
> The "product" documents have a property of SKU that is a string. I 
> would like to form a query to get a list of all the product SKUs. Does 
> this require a view in the design document or can it be done all in one
request? Thank you.

  Your "or" doesn't make sense there.  You can do it with or without a view
and in either case you can do it in one request.

  It looks like you can probably just use alldocs with a start and end key
specified limiting to the doc IDs that start with "product-".

  You could also build a view that maps sku -> [something] for all documents
of type product and then traverse that.  The value could be null, or
something you might want to know when looking at a sku.

  Or if you have different ways of looking at products, you could use that
as the key and the sku as the value and chop it up more neatly from there.

--
dustin



Re: Get all documents of a certain type.

Posted by Dustin Sallings <du...@spy.net>.
"Kevin Burton" <rk...@charter.net>
writes:

> In my Couch database I have a mixture of documents. The documents that I am
> interested in have an Id of 'product-xxxxxxx' or 'order-xxxxxx'. The
> "product" documents have a property of SKU that is a string. I would like to
> form a query to get a list of all the product SKUs. Does this require a view
> in the design document or can it be done all in one request? Thank you.

  Your "or" doesn't make sense there.  You can do it with or without a
view and in either case you can do it in one request.

  It looks like you can probably just use alldocs with a start and end
key specified limiting to the doc IDs that start with "product-".

  You could also build a view that maps sku -> [something] for all
documents of type product and then traverse that.  The value could be
null, or something you might want to know when looking at a sku.

  Or if you have different ways of looking at products, you could use
that as the key and the sku as the value and chop it up more neatly from
there.

-- 
dustin


Re: Get all documents of a certain type.

Posted by Jens Alfke <je...@couchbase.com>.
On Nov 6, 2012, at 1:58 PM, Kevin Burton <rk...@charter.net> wrote:

> In my Couch database I have a mixture of documents. The documents that I am
> interested in have an Id of 'product-xxxxxxx' or 'order-xxxxxx'. The
> "product" documents have a property of SKU that is a string. I would like to
> form a query to get a list of all the product SKUs. Does this require a view
> in the design document or can it be done all in one request? Thank you.

It requires a view. Its map function should do something like emitting as a key the SKU property of each document whose ID indicates it’s a product.

—Jens