Oh, I hear your point. Thanks for the insight!

Is there any way to traverse a relationship from a MapBlock? 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?

Cheers,
Ragu

On Sunday, April 20, 2014 9:07:40 PM UTC-7, Jens Alfke wrote:
>
>
> On Apr 20, 2014, at 7:27 PM, Ragu Vijaykumar <[email protected]<javascript:>> 
> wrote:
>
> I've been defining a bunch of MAPBLOCKs for my view and I was wondering 
> whether there was anyway of converting the (NSDictionary* doc) parameter to 
> a CBLModel inside my map function? Ideally, I'd want to convert the doc to 
> a CBLDocument* object, and then use the CBLModelFactory to create the right 
> type of CBLModel for me, or nil, and then I can check if the CBLModel is 
> the right kind of model I want (isKindOfClass). If so, I can then do my map 
> processing using the properties of the model.
>
>
> I can see the appeal of this, as it makes your map functions look more 
> like the rest of your code and lets you use the higher-level abstractions 
> that the model provides. But I think it’s too heavyweight. Map functions 
> need to be fast or they’ll become a bottleneck in view indexing. (I’m 
> coincidentally doing some optimization work on indexing right now, so this 
> is on my mind.)
>
> Also, I think there’s too much state involved in CBLDocument and CBLModel 
> to be safe to use in a map function. The map function may be run on a 
> background thread (if you use a live query), and in the future we may 
> parallelize it so it runs on several threads at once, if the CPU has enough 
> cores.
>
> —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/c9fb0923-3a90-4fad-b06b-bcc1c34d433c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to