incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nils Breunese <N.Breun...@vpro.nl>
Subject RE: get by property
Date Fri, 23 Sep 2011 12:10:29 GMT
You could create views for every property you want to be able to use as a lookup key (by_flash,
by_ram, by_eeprom, by_package) and emit the property value as the key: emit(property_value,
null); Then you can query the view for the property you're looking for, e.g /db/_design/ddoc/_view/by_flash?key="8kbyte"

Or you could create a single view which indexes all properties with their values by emitting
the property key and value as a complex key: emit([property_key, property_value], null); Then
you can query the view like this: /db/_design/ddoc/_view/all_properties?key=["Flash","8kbyte"]

Nils.
________________________________________
Van: Markus Burrer [mb@embedit.de]
Verzonden: vrijdag 23 september 2011 11:14
Aan: user@couchdb.apache.org
Onderwerp: get by property

Hi, I have a document like this

|{
    "|_id|":|"ATmega8A-PU"|,
    "|_rev|":|"5-76258a717723df03afe068a7e001d108"|,
    "|name|":|{
        "|de|":|"ATmega8A-PU"|,
        "|en|":|"ATmega8A-PU"|
    }|,
    "|properties|":|{
        "|Flash|":|"8kByte"|,
        "|RAM|":|"1kByte"|,
        "|Eeprom|":|"512Byte"|,
        "|Package|":|"DIP28S"|
    }|,
    "|record_type|":|"article"|
}|

I want to get all documents with the same property, for example with the
package "DIP28S" or all docs with the property "RAM":"1kByte".

How should the view look like?

Kind Regards
Markus
------------------------------------------------------------------------
 VPRO   www.vpro.nl
------------------------------------------------------------------------

Mime
View raw message