couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Woodward <m...@mattwoodward.com>
Subject Writing View to Get Unique Values in Arrays Across Documents
Date Wed, 19 Jan 2011 23:22:49 GMT
Been banging my head on this one only briefly but figured I'd ask before
banging further.

I have documents with a property that's an array. I want to write a view to
retrieve all documents based on an ID in the document (not the document ID,
but another ID that will exist in multiple documents), and the ultimate end
result I want is the distinct/unique values from the array data across these
documents.

To give a concrete example, let's say I have the following two documents:

DOCUMENT 1:
idToRetrieveBy: 1
arrayData: ['Homer','Marge','Bart']

DOCUMENT 2:
idToRetrieveBy: 1
arrayData: ['Homer','Marge','Bart','Lisa','Maggie']

>From the view, what I'd want to get back is:
['Homer','Marge','Bart','Lisa','Maggie']

Any ideas on how to go about that, or is that something I'd have to crunch
on the application side of things?

Thanks.

-- 
Matthew Woodward
matt@mattwoodward.com
http://blog.mattwoodward.com
identi.ca / Twitter: @mpwoodward

Please do not send me proprietary file formats such as Word, PowerPoint,
etc. as attachments.
http://www.gnu.org/philosophy/no-word-attachments.html

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message