couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Travis Jensen <travis.jen...@gmail.com>
Subject Show functions accessing two (or more) documents
Date Tue, 06 Sep 2011 18:05:51 GMT
I have a question about "joining" documents as part of a show function. For
illustration's sake, let's say I have POS data stored in CouchDB (this isn't
my actual use case, but it is an easily understood use case, so let's go
with it. In other words, don't tell me what I'm doing wrong with invoices,
tell me what I'm doing wrong with Couch :). Among other things, the POS has
the following:

{ "_id": "invoice1001",
  "customer": "customer125",
  "items": [ { "itemnum": "item1", "qty": 8, "unitprice": 1.25 },
             { "itemnum": "item125", "qty": 1, "unitprice": 79.99 } ]
}

Customers are stored in the database as well:

{ "_id": "customer125",
  "address": "123 N Main St"
  "city": "Smallville"
  "state": "KY"
  "zip": "20000"
}

And items exist in the database:

{ "_id": "item125",
  "name": "Foobazzer 1.0",
  "desc": "A widget for foobazzing"
}

Now I'd like to build a printable invoice. This seems like a perfect job for
a show function, but I don't know how to do the "join" part where I look up
the customer and items based on their respective IDs.  Is this problem
solvable on the server?

Thanks.

tj
-- 
*Travis Jensen*
***
*Read the Software Maven @ http://softwaremaven.innerbrane.com/
Read my LinkedIn profile @ http://www.linkedin.com/in/travisjensen
Read my Twitter mumblings @ http://twitter.com/SoftwareMaven
Send me email @ travis.jensen@gmail.com

**What kind of guy calls himself the Software Maven???**

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