h2. Quick Start
{note}This is currently WIP.{note}
h3. {excerpt}5 minutes Quick start tutorial{excerpt}
Download the {{couch4j}} jar and the dependencies or add the couch4j dependency to your [Maven pom|couch4j:Maven].
The following code snippet shows the main building blocks of the couch4j library:
* CouchDbClient - represents the client connection to the CouchDB server
* Database - a single database
* Document - the document stored in CouchDB
{code:java}
CouchDbClient client = new DefaultCouchDbClient(); // Reuse a single instance of CouchDbClient and Database
Database database = client.getDatabase("couch4j");
ViewResult allDocs = database.fetchAllDocuments();
System.out.format("Number of documents: %d%n", allDocs.getTotalRows());
for (ViewResultRow row : allDocs) {
// Row
System.out.println(row.getId());
// Document
Document doc = row.getDocument();
System.out.println(doc.getId());
System.out.println(doc.toJson());
// OR
// If the value of the row is an array
JSONArray ary = row.getValueAsArray();
// If it is an object
JSONObject obj = row.getValueAsObject();
}
{code}
h3. More
{children:page=Use Cases|excerpt=true|sort=title}
{note}This is currently WIP.{note}
h3. {excerpt}5 minutes Quick start tutorial{excerpt}
Download the {{couch4j}} jar and the dependencies or add the couch4j dependency to your [Maven pom|couch4j:Maven].
The following code snippet shows the main building blocks of the couch4j library:
* CouchDbClient - represents the client connection to the CouchDB server
* Database - a single database
* Document - the document stored in CouchDB
{code:java}
CouchDbClient client = new DefaultCouchDbClient(); // Reuse a single instance of CouchDbClient and Database
Database database = client.getDatabase("couch4j");
ViewResult allDocs = database.fetchAllDocuments();
System.out.format("Number of documents: %d%n", allDocs.getTotalRows());
for (ViewResultRow row : allDocs) {
// Row
System.out.println(row.getId());
// Document
Document doc = row.getDocument();
System.out.println(doc.getId());
System.out.println(doc.toJson());
// OR
// If the value of the row is an array
JSONArray ary = row.getValueAsArray();
// If it is an object
JSONObject obj = row.getValueAsObject();
}
{code}
h3. More
{children:page=Use Cases|excerpt=true|sort=title}