couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Duc Phan <>
Subject Join Query View
Date Thu, 11 Nov 2010 16:35:12 GMT
Hello all,
I am fairly new to couchDB and the Map/Reduce framework.
I am having problems creating a join view.

For example:
I have multiple documents in these two formats
Type : Inventory
ID: someID
Name: someName
Location: someLocation
Serial: someSerial

Type: Machine
Serial: someSerial
Model: someModel
OS: someOS
RAM: someRAMsize
HD: someHDsize

Here is what I am trying to do...
in SQL > Select ID, Name, Location, Type, Model, OS, RAM, HD from Inventory,
Machine where Inventory.Serial = Machine.Serial
That would join the two tables where the Serials match up.

How would I do that in couchDB where I have multiple documents with Type:
Inventory and Type: Machine
I would like the output to be something like:
for all the machines
I have read couchDB the definitive guide and many blogs but I still haven't
found a way to solve my problem.

My attempt:
Map: function(doc){
if (doc.Type == "Inventory"){
emit ([doc.SERIAL,0],doc);}
else if (doc.Type == "Machine"){

Reduce: ? What should I do here.

Thank you in advance for any suggestions or help.

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