This post marks the second in a series about the Couchbase Mobile stack. You can find the first post here. It covers installing Couchbase Server. In this post, we’ll examine part of the Couchbase Web Console (CWC).
To get comfortable with the whole stack, it’s great to install and run everything on your development machine. In this series of posts, I’ll walk through the steps get to started with each component. I’ll show how to do a little extra exploring along the way, too.
I’ll only do minimal configuration. This is not intended to explain what you need for a production environment. I assume you’re familiar with some basics of NoSQL, have some understanding of Couchbase, and know how to build apps in something like Java, Android, or iOS. If you want to read up on NoSQL databases or Couchbase, you can find lots of resources on the Couchbase site.
Couchbase is open-source. Everything I’ll use here is free to try out. See the end of the post for more resources if you need help.
Exploring Couchbase Server
Now that we have an instance up and running1, we can try a few things out. Couchbase Server has a built-in web-based administration interface (Couchbase Web Console) and a large number of command line tools. You can also perform interesting manipulations through its REST interfaces easily. This gives us three ways to delve in without writing any code. In this post, we’ll start with CWC.
The Couchbase Web Console
We saw the Overview panel of the Web Console during our initial installation. The interface has nine main panels in total. For the purpose of understanding Couchbase Mobile, we only need to concern ourselves with the Data Buckets panel.
Click on the Data Buckets tab in the navigation bar. If you loaded the beer sample bucket, click on the arrow to the left of the bucket tile “beer-sample”. You should see information similar to what’s shown in the following screenshot.
This gives general information about the bucket. You can see some of the parameters used during setup reflected here.
In the upper right corner, you’ll see two buttons, “Documents” and “Views”. Select “Documents”. This brings up a list of documents in the bucket. Each entry shows a limited version of the document id and contents.
Click on the document id to bring up the full document contents. You can also directly edit and save changes to documents here.
Views define a static index in your database. Couchbase achieves this using a map/reduce approach.
Since the index gets created at the time of processing the document, we call this a “static” index. This speeds up queries. In contrast, with Couchbase, you can use the N1QL query language to create queries on the fly. N1QL queries are overall more powerful and flexible, but will typically be slower to execute.
You can read more about Views here. I emphasize Views because Couchbase Lite uses them for queries. Currently Couchbase Lite doesn’t support N1QL.
The beer sample has two Views already defined. To see them, click on the Data Buckets tab again. Now, instead of clicking “Documents” in the upper right, click “Views”. You’ll see the following information.
Click on “Production Views”. In the list of Views, click “brewery_beers” to get to this page.
To see the index created by the View, click “Show Results” to the right, above the third pane shown.
To try out Views yourself, you can copy a Production View and modify it. Jump back two steps to the introduction to Views. Look for the “Copy to Dev” button. Click that. Hit “Copy” in the dialog that pops up. You’ll be taken to “Development Views” where you can edit views and documents and test out the results.
In the next post in this series I’ll show some ways to work with Couchbase Server from the command line. After that I’ll move on to Sync Gateway. Then we’ll look at a sample app using Couchbase Lite. Finally, we’ll use that sample app to loop back and see how everything ties together.
[buttongroup][button style=”btn-link btn-lg” icon=”fa fa-arrow-left” align=”left” iconcolor=”#dd3333″ type=”link” target=”false” title=”Previous: Installing Couchbase Server” link=”https://www.couchbase.com/blog/getting-comfortable-with-couchbase-mobile-installing-couchbase-server/” linkrel=””][button style=”btn-link btn-lg” icon=”fa fa-arrow-right” align=”left” iconcolor=”#dd3333″ type=”link” target=”false” title=”Next: Couchbase Server via the Command Line” link=”https://www.couchbase.com/blog/getting-comfortable-couchbase-mobile-couchbase-server-command-line/” linkrel=””][/buttongroup]
You can follow me personally at @HodGreeley