Browser and CLI Access
Edit this article in GitHub
Version 2.3

Browser and CLI Access

You can browse and access documents in Couchbase using browser and command line tools without writing any code. This can be helpful to you if you simply wish to inspect cluster data without writing code. You can access individual documents using the command line and web console.

Command-Line

You can access documents in Couchbase using command line interfaces. You can use the cbc tool for simple document lookups by their IDs (or keys) and the cbq tool to issue N1QL queries. This section will discuss the installation and usage of the cbc tool, and is targeted towards Linux and Mac OS X users (though cbc can also be used on Windows).

Installing the command-line KV client

To use the cbc tool, first install the C SDK. Note that you will also need to install the command line tools.
Debian/Ubuntu
wget http://packages.couchbase.com.s3.amazonaws.com/releases/couchbase-release/couchbase-release-1.0-2-amd64.deb
sudo dpkg -i couchbase-release-1.0-2-amd64.deb
sudo apt-get update
sudo apt-get install libcouchbase2-bin
CentOS/RHEL
wget http://packages.couchbase.com.s3.amazonaws.com/releases/couchbase-release/couchbase-release-1.0-2-x86_64.rpm
sudo rpm -ivh couchbase-release-1.0-2-x86_64.rpm
sudo yum install libcouchbase2-bin
Mac OS X
brew install libcouchbase
Note: The cbc tool is part of the C SDK. Refer to C SDK for other installation options.

Using the command-line KV client

The cbc command contains subcommands that perform various operations on the server. Some subcommands are:
  • cbc create (create/update documents)
  • cbc cat (retrieve a document)
  • cbc rm (remove a document).
To point the client at a cluster, provide one of the cluster nodes using the -U argument:
$ cbc cat document-id -U couchbase://node-ip-or-hostname

You can store a document using the cbc create command.

$ cbc create document_id -V '{"json":"value"}'
document_id         Stored. CAS=0xd0d92f40500
Note: The command line client is not JSON-aware. If dealing with JSON documents, ensure that values passed to it are well formed JSON because the cbc program does not do any validation.

You can retrieve a document using the cbc cat subcommand.

$ cbc cat document_id
document_id          CAS=0xe0004ea40100, Flags=0x0. Size=16
{"json":"value"}

You can find out more about the cbc command by referring to your local man pages or by viewing its documentation.

Using the command-line query shell (cbq)

You can use the cbq program as a command line query shell to issue N1QL queries in couchbase. cbq is available on all cluster nodes and does not require a separate installation. Simply run cbq from the Couchbase installation directory ( /opt/couchbase/bin/cbq on Linux and "/Applications/Couchbase Server.app/Contents/Resources/couchbase-core/bin/cbq"). Once in the shell, you should be greeted by a prompt and ready to issue any N1QL query.
$ ./cbq
cbq> select airportname FROM `travel-sample` WHERE airportname IS NOT NULL LIMIT 1;
{
    ...
    "results": [
        {
            "airportname": "Abbeville"
        }
    ]
    ...
}

Couchbase Web Console Document Access

You can use the Couchbase Web Console to view, edit, and create JSON documents up to 2.5KB in size. To access documents using the Couchbase Web Console:
  1. Navigate your browser to a cluster node. Type the address of the cluster with the admin port (8091). Use your username (usually Administrator). The password is the password you used when setting up the cluster.

  2. Once logged in, access the Buckets view, by left-clicking on the Buckets tab, in the navigation panel at the left-hand side. The Buckets view displays all buckets currently defined on your system. In the illustration below, the travel-sample bucket is displayed:

  3. Left-click on the Documents tab, at the right-hand side of the travel-sample bucket-row. This brings up the Documents view, which lists the documents contained by the selected bucket:

  4. To retrieve a document, enter the document ID into the Look Up ID field, at the upper-right; then left-click on the adjacent button. The Documents Editing page now appears. This allows you to edit the selected document.

  5. To create a new document, return to the Documents view, and click on Add Document, at the upper right. This brings up the Create Document dialog, which allows you to enter a Document ID:

  6. Enter an appropriate ID, then save. This bring up the Documents Editing view.

Couchbase Web Console Query Accesss

You can use the Query Workbench to issue queries using the web console.