Quick start

To get started, follow these instructions to download and install the tutorial application. If you do this, you will have the code set up so you can just follow along as you read through the rest of the tutorial.

  1. Download Couchbase Server and install it. Make sure to install the beer-sample bucket when you run the wizard because this tutorial application works with it.

  2. Clone the repository and install dependencies (Express and Jade):

    $ git clone git://github.com/couchbaselabs/beersample-node 
    Cloning into 'beersample-node' #... 
    $ cd beersample-node 
    $ npm install
  3. Set up the views.

    You can set up the views manually by using the Couchbase Server administration console or by invoking the beer.js script located in the beersample-node directory.

    To set up the views with the script, enter the following command:

    $ node beer.js --setup

    To set up the views manually, open the Couchbase Server administration console. In the beer design document, create a development view called by_name, then promote it to a production view. (The beer-sample bucket might already have a production design document named beer with a by_name view. If it does, you can skip this step.) Here's the JavaScript map function for the view:

    function (doc, meta) {
        if (doc.type && doc.type == "beer") {
            emit(doc.name, null);
        }
    }

    Create another design document called brewery, add a view called by_name, and publish it to a production view. Here's the JavaScript map function for the view:

    function (doc, meta) {
        if (doc.type && doc.type == "brewery") {
            emit(doc.name, null);
        }
    }
  4. Invoke the beer.js script:

    $ node beer.js
    Server running at http://127.0.0.1:1337/
  5. In your web browser, navigate to http://localhost:1337/welcome, and enjoy the application!