On Mar 1, 2014, at 11:24 PM, archit agarwal <[email protected]> wrote:

> Now I am confused about how to implement the reduce function so I get 
> messages in which => either from is X OR to is X 
> Any help on this would be really appreciated.

That's not the job of a reduce function. Reducing is like aggregation in SQL -- 
"SUM()", "MAX()", "AVERAGE()", etc.

What you're asking for in this query is a sub-range: "messages with X" for some 
X. So what you want is a map function that emits keys that are ordered by the 
other person's identity, so you can then query for a specific person.

What I'd do is
                if([to isEqualToString:myuid])
                    emit(@[from,timestamp],nil);
                else if([from isEqualToString:myuid])
                    emit(@[to,timestamp],nil);
Then query by
        query.startKey = @[other];
        query.endKey = @[other, @{}];

--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/4D860C1B-CA55-4831-825B-815FD04B3FFA%40couchbase.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to