Querying a view on Couchbase server from CBL?

45 views
Skip to first unread message

Manuel B

unread,
Jun 13, 2014, 2:49:20 PM6/13/14
to mobile-c...@googlegroups.com
Hi there,

I suspect that this is a beginners question, but I feel like from reading the documentation and having read a few sections of the Developing with Couchbase Server book I still haven't quite figured out how it all works.

We are developing an Android app and we have got the sync for documents already set up. Now when it comes to the Views we created it with JavaScript on the server, because first I thought it would be possible to just query a View on the server from within the app and CBL.

This perception has now changed and from reading the ToDo app code, you need to write your own View in CBL and then query that one.

How does this work then - is there a way to sync the index of the View as well or do you have to keep one locally and one on the server.
To me it seems just a bit of a performance issue to think that the Android device has to do the same map/reduce jobs as the Couchbase server.

I would really appreciate if someone could shed some light on this issue.

Thanks in advance,

Manuel

Jens Alfke

unread,
Jun 13, 2014, 3:23:25 PM6/13/14
to mobile-c...@googlegroups.com
On Jun 13, 2014, at 11:49 AM, Manuel B <manu...@gmail.com> wrote:

We are developing an Android app and we have got the sync for documents already set up. Now when it comes to the Views we created it with JavaScript on the server, because first I thought it would be possible to just query a View on the server from within the app and CBL.

No. That would require an active connection to the server, but Couchbase Lite is designed to work offline, so except for replication it uses only its local database.

Views in Couchbase Server are completely independent of those in Couchbase Lite. The replication model considers only documents, not views.

How does this work then - is there a way to sync the index of the View as well or do you have to keep one locally and one on the server.
To me it seems just a bit of a performance issue to think that the Android device has to do the same map/reduce jobs as the Couchbase server.

It would probably be a lot more expensive to download a view index from the server than to generate it locally. And the client has to be able to generate and update views on its own as it makes local changes to the database.

—Jens

Manuel B

unread,
Jun 13, 2014, 3:43:54 PM6/13/14
to mobile-c...@googlegroups.com
Alright, thanks a lot for your feedback. I was just wondering why there's the possibility to create Views on Couchbase Server, because the Views in JS are also mentioned in the Mobile Developers Guide, but I assume that's just to get a deeper understanding.

So as long as I'm using CBL and not another SDK that uses REST I won't need the Views on the server, but can just replicate the documents. That's pretty good.

manuel

Jens Alfke

unread,
Jun 13, 2014, 6:22:07 PM6/13/14
to mobile-c...@googlegroups.com

On Jun 13, 2014, at 12:43 PM, Manuel B <manu...@gmail.com> wrote:

Alright, thanks a lot for your feedback. I was just wondering why there's the possibility to create Views on Couchbase Server

Couchbase Server and Couchbase Lite both inherited their index/query functionality from CouchDB, so they have the same type of map/reduce views. But the views don’t sync with each other.

—Jens

Reply all
Reply to author
Forward
0 new messages