On Sunday, 17 April 2016 23:22:05 UTC+2, Jens Alfke wrote:
>
> Could you post the actual map function you’re using? What you posted in 
> the first message won’t compile and I can’t tell from it what the docs look 
> like. And/or show the JSON of the doc types involved. 
>

    [self.view setMapBlock: MAPBLOCK({
        if ([doc[@"doctype"] isEqualToStringCaseInsensitive: @"orderline"]) 
{
            NSInteger orderId = [doc[@"orderId"] intValue];
            if (orderId != -1) {
                emit(@[@(orderId)], @1);
            }
        }
        if ([doc[@"doctype"] isEqualToStringCaseInsensitive: @"order"]) {
            NSInteger orderId = [doc[@"id"] intValue];
            NSString *firstName = [doc[@"firstName"] length] ? 
doc[@"firstName"] : @"";
            NSString *lastName = [doc[@"surName"] length] ? doc[@"surName"] 
: @"";
            NSString *email = [doc[@"email"] length] ? doc[@"email"] : @"";
            NSString *phone = [doc[@"phone"] length] ? doc[@"phone"] : @"";
            NSNumber *vip = [doc[@"vip"] intValue] ? @1 : @0;
            NSString *avatarUrl = [doc[@"avatarUrl"] length] ? 
doc[@"avatarUrl"] : @"";
            emit(@[@(orderId), firstName, lastName, email, phone, vip, 
avatarUrl], @0);
        }

    }) reduceBlock: ^id(NSArray *keys, NSArray *values, BOOL rereduce) {
        return [CBLView totalValues: values];
    } version: @"0.44"];
 
I dont see how this could work; grouplevel 1 wont give me the extra 
properties I need and grouplevel 7 wont give me proper aggregation.
(what I need is several properties of doc type X and the count of doc type 
Y that is related to an instance of type X, in a single query)

-- 
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/9bf8d9fd-6b20-4590-841b-5c52b8e61db4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to