couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paweł Stawicki <pawelstawi...@gmail.com>
Subject Re: How to make equivalent of WHERE on JOINed table in CouchDB?
Date Sat, 12 Dec 2009 22:31:01 GMT
> If I right understand your question:
>
> Look at git commit 926af4ba11093dcaff13bea0e4ed9addfc67ab10

I don't know how to look at this specific commit :(

> "include_docs now take an _id (as well as a _rev) in the emitted value, to
> load docs other than the one doing the emitting. This means you can have one
> doc list a
> set of other docs to load in a single query. Enjoy!"
>
> function(doc) {
>  if (doc.type == "Car") {
>    emit(doc.brand, null); // emits car document
>    emit(doc.brand, { _id: doc.person_id }); // emits whole person document
>  }
> }
>
> Then query your view using include_docs=true, key=Ferrari and you will get
> both Car and Person in a single query.

Maybe this is something wrong with my CouchDB implementation. I have
version 0.10.0, not the newest one, so it's a pity I can't look at
this commit. But when I did what you told me, I got just car document,
not person one:

{"id":"133fec564f0b68f30a7b7d63fe8235d2","key":"Ferrari","value":{"_id":"61fe9c6c226b978f74b76329191806b3"},"doc":{"_id":"133fec564f0b68f30a7b7d63fe8235d2","_rev":"3-5af80a278515fc2caa4290598386050e","person_id":"61fe9c6c226b978f74b76329191806b3","brand":"Ferrari","reg_number":"za3223d"}}

Idea of having access in map function to other documents is great, I
hope I'll manage to get it working.

Best regards
Pawel Stawicki

Mime
View raw message