Couchbase Travel App

Couchbase Travel is a sample web application that demonstrates how to interact with the Couchbase query service via the Node.js SDK.

You can download the complete source code and then build and run the app. While the app runs, you can view the log of N1QL queries that it sends. The documentation for the travel app illustrates the data model and walks through the N1QL queries used to select flights.

The travel app is written in Node.js and incorporates the following frameworks:

The application allows users to find flights by entering airports and travel dates. For the airport entries, the app uses a N1QL query bound to an Angular type ahead directive to suggest airport names based on the first few letters entered.

If you want to try the sample app first, without having to build and run the sample code, take a look at the travel app hosted at http://try.couchbase.com. See Using the Travel App for guidelines on how to use the travel app.

Building and Running the Travel App

To start with, it's easiest if you run Couchbase Server and the travel sample app on the same machine. It's not required to run your development environment this way it's just easier to start a development environment with components running locally. Advanced "MDS" configurations are supported. To build and run the sample travel app follow these steps:

You do not need to provision the cluster "manually" after installation. The sample application can take care of this for you. If you have a Couchbase instance already installed and configured, you can just use the application (that is, you don't need to reinstall Couchbase Server to try this app).

Install node.js on the machine that is running Couchbase Server. This application uses recent JavaScript features (ES6) for provisioning (fat arrow functions, promises, classes). Please make sure the version of node.js you are installing is 4.0.0 or higher.

In a terminal window on the machine that is running Couchbase Server, enter the following commands to install the sample application:

The command sequence creates a new directory, clones the GitHub repository that contains the travel app, and installs dependencies.

If you already have a configured instance of Couchbase Server, edit the config.batinc file in the root of the cloned repository and change the username and password fields to match the credentials you entered when you set up Couchbase Server.

To provision the travel-sample application and setup a cluster from the instance of Couchbase Server that you downloaded and installed, enter the following command from the ~/try-cb directory:

$ npm run build

Using a script defined in the package.json file under the "build" section for the application, npm automatically provisions a cluster on the installed Couchbase instance. The provisioning process outputs messages to the terminal. Provisioning and starting the app can take up to two minutes to complete based on the speed of your environment. Upon completion, the app outputs a message with the app login URL. You only need to run 'npm run build' once, and if it's run again it will not re-provision the Couchbase instance. You'll see messages similar to this one: