couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dustin Sallings <dus...@spy.net>
Subject Re: Get all documents of a certain type.
Date Tue, 06 Nov 2012 22:10:35 GMT
"Kevin Burton" <rkevinburton@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


Mime
View raw message