On Apr 21, 2014, at 9:30 AM, Ragu Vijaykumar <[email protected]> wrote:

> Is there any way to traverse a relationship from a MapBlock?

No; a map function by design is only allowed to look at the document passed 
into it. Otherwise if documentB changes but documentA doesn't, then the index 
values emitted by documentA would be out of date.

> I have a DocumentA that has a relationship to DocumentB, and I want to return 
> all DocumentAs that have a specific field value in DocumentB. Is there anyway 
> to do this with a MapBlock?

You'll need to do this with two views and a hand-made join:
- View A maps from documentA to documentB, i.e. its map function detects a 
documentA and emits its documentB ID.
- View B maps the specific field of documentB, i.e. emits that field.

First you query view B to find all documentBs that have that value in them. 
Then you query view B setting the 'keys' property to that array of documentB 
IDs, and you'll get rows for all the documentAs.

--Jens

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/3C1C6F27-4FCF-4015-B4C9-B78D29DC0D87%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to