Quick one, is it a must to have a unique key in the emit(key,value) function?

29 views
Skip to first unread message

xiangyu wang

unread,
Feb 21, 2015, 2:44:36 AM2/21/15
to mobile-c...@googlegroups.com
Just like in normal sql. we do SELELCT WHERE like:

select valuea from atable where keya=a and keyb=b.

The result should be a list of rows that have keya == a and keyb == b.

And what I'm trying in couchbase lite is to 

emit(@[doc[keya], doc[keyb]], doc[valuea])

and when querying, I'm expecting to get a list of doc[valuea] that match the keya == a and keyb == b.

The question is, is it the way emit is meant to be used? And should I have multiple docs that share the same key in a index?

-Sean

Jens Alfke

unread,
Feb 22, 2015, 12:57:43 AM2/22/15
to mobile-c...@googlegroups.com
Yes, it’s fine for an index to have multiple rows with the same key.

(However, two documents can’t have the same key/ID.)

—Jens
Reply all
Reply to author
Forward
0 new messages