Intersection and Union

8 views
Skip to first unread message

Brendan Duddridge

unread,
Jun 28, 2015, 8:29:56 PM6/28/15
to mobile-c...@googlegroups.com
Hi,

Is there a CBL for iOS equivalent to doing an SQL INTERSECTION or UNION?

Or do I basically have to load in two sets of results and use NSSet or something like that to get an intersection or union?

Thanks,

Brendan

Jens Alfke

unread,
Jun 28, 2015, 8:35:10 PM6/28/15
to mobile-c...@googlegroups.com

On Jun 28, 2015, at 5:29 PM, Brendan Duddridge <bren...@gmail.com> wrote:

Is there a CBL for iOS equivalent to doing an SQL INTERSECTION or UNION?
Or do I basically have to load in two sets of results and use NSSet or something like that to get an intersection or union?

No, there isn’t any support for combining the results of multiple queries. You’ll need to merge them yourself. Often you can do it without having to dump everything into an NSSet; since each enumerator will traverse the keys in increasing order, you can often just do pairwise comparison of keys while enumerating both queries in parallel.

Another option is to define another view that will generate the results you want, for example emitting two properties of a document to do an effective UNION of views that emit one of the properties.

—Jens
Reply all
Reply to author
Forward
0 new messages