Views based on channel


I want to be able to allow users to view data from a specific channel one at a time. I figured that I’d be able to create a view with a compound key that has the channels property (which itself is an array) but if there is a best practice or an example of this that would be much appreciated (in iOS and/or android)


I assume you have a custom property that’s an array of the channels the document is in. (There won’t be one by default; Couchbase Lite doesn’t automatically see what channels a document is in.)

Then write a map function that iterates the list of channels and emits each one of them as the key. Now you have an index that maps channel names to documents, and you can query that with a specific key or range of keys.


Thanks (yeah I do have the channels property set on the documents). I’ve been using this for over a year and I still haven’t fully adapted to views :smile: