1# Couchbase Node.js Client
2
3This library allows you to connect to a Couchbase cluster from Node.js.
4It is a native Node.js module and uses the very fast libcouchbase library to
5handle communicating to the cluster over the Couchbase binary protocol.
6
7[![Build Status](http://cbsdkbuilds.br19.com/buildStatus/icon?job=cb-node)](http://cbsdkbuilds.br19.com/job/cb-node/)
8
9
10## Useful Links
11
12Source - http://github.com/couchbase/couchnode
13
14Bug Tracker - http://www.couchbase.com/issues/browse/JSCBC
15
16Couchbase Node.js Community - http://couchbase.com/communities/nodejs
17
18
19## Installing
20
21To install the lastest release using npm, run:
22```
23npm install couchbase
24```
25
26To install the in development version directly from github, run:
27```
28npm install git+https://github.com/couchbase/couchnode.git
29```
30
31
32## Introduction
33
34Connecting to a Couchbase bucket is as simple as creating a new Connection
35instance.  Once you are connect, you may execute any of Couchbases' numerous
36operations against this connection.
37
38Here is a simple example of instantiating a connection, setting a new document
39into the bucket and then retrieving its contents:
40
41```javascript
42    var couchbase = require('couchbase');
43    var cluster = new couchbase.Cluster();
44    var db = cluster.openBucket('default');
45
46    db.upsert('testdoc', {name:'Frank'}, function(err, result) {
47      if (err) throw err;
48
49      db.get('testdoc', function(err, result) {
50        if (err) throw err;
51
52        console.log(result.value);
53        // {name: Frank}
54      });
55    });
56```
57
58
59## Mock Testing
60
61As part of this library, we include a mock version of the client that supports
62nearly the exact same feature set as the library itself, but which does not
63require that a server be configured.  Note that these Mock connections currently
64are per-instance, if another connection is instantiated, none of the data will
65be shared.
66
67Using the Mock is as simple as this:
68```javascript
69    var couchbase = require('couchbase').Mock;
70    var db = new couchbase.Connection();
71```
72
73
74## Documentation
75
76An extensive documentation is available on the Couchbase website.  Visit our
77[Node.js Community](http://couchbase.com/communities/nodejs) on
78the [Couchbase](http://couchbase.com) website for the documentation as well as
79numerous examples and samples.
80
81
82## Source Control
83
84The source code is available at
85[https://github.com/couchbase/couchnode](https://github.com/couchbase/couchnode).
86Once you have cloned the repository, you may contribute changes through our
87gerrit server.  For more details see
88[CONTRIBUTING.md](https://github.com/couchbase/couchnode/blob/master/CONTRIBUTING.md).
89
90To execute our test suite, run `make test` from your checked out root directory.
91
92
93## License
94Copyright 2013 Couchbase Inc.
95
96Licensed under the Apache License, Version 2.0.
97
98See
99[LICENSE](https://github.com/couchbase/couchnode/blob/master/LICENSE)
100for further details.
101