> On Sep 24, 2014, at 7:31 AM, Steve <[email protected]> wrote: > > How would I join the documents on the client (phone)? Is it OK to query > Couchbase Lite for all the documentB docs, iterate through each of them > querying Couchbase Lite using doc ID of documentA (stored in documentB)? I > have 1400+ documents so this would result in 1400 queries!
There are a couple of tricks for this. The one that's relevant to your case, I think is this: You can make an emitted row in the index "pretend" to come from a different document. If your map function emits a value that's a dictionary with an "_id" key, whose value is a document ID, then the resulting index row will act as though it came from that document instead. So calling CBLQueryRow.document will load the document you specified. (You can still find the actual source document via the sourceDocumentID property.) (There are also ways to make an index merge values from multiple related documents. You design the keys so they're adjacent, then use grouping in the query to reduce those rows together. This may be overkill for your needs, though.) —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/8771DDC9-AE12-4A01-B223-A6AB0247B99E%40couchbase.com. For more options, visit https://groups.google.com/d/optout.
