Install and Start Using the Node.js SDK with Couchbase Server

Preparing for Installation

Install Couchbase Server first, if you haven’t done so already.
Refer to the installation guide for server installation instructions.

The installation process will build libcouchbase (LCB) and other dependencies for you, so you will need the build tools for your platform, such as Visual Studio or GCC (more details in the LCB installation pages).

Installing the SDK

Information on new features, fixes, known issues, as well as information on how to install older release versions is in the release notes.

Hello Couchbase

Once you’ve installed the SDK, you can run this simple code snippet showcasing some of its features.
Before running, be sure to replace localhost with the hostname of a node in your cluster, if running the SDK on a different host.

The above shows how to upsert (insert-or-update) a single document and execute a query searching for specific criteria, in this case, any user who has an interest in African Swallows.

The code creates a Cluster object representing a Couchbase cluster.
A connection to a data bucket is established using Cluster.openBucket, returning a Bucket object.
The returned Bucket object is then used to perform document operations, and then executes a query.

Additional Resources

The source code repsitory is at https://github.com/couchbase/couchnode where you can see all the latest development.
You can also contribute to the project - follow instructions in the source repository

Using an external C SDK

The node.js SDK comes with an embedded version of the C SDK in order to streamline the installation experience.
It may be necessary to use an external version of the C SDK if you wish to:

Use SSL connections with Couchbase

Use a version of the C SDK contains bug fixes not available in the embedded version