Quick Start
| This is currently WIP. |
5 minutes Quick start tutorial
Download the couch4j jar and the dependencies or add the couch4j dependency to your Maven pom.
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
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(); }
More
- Change notifications
- Create databases
- Delete databases
- Delete documents
- Fetch attachments
- Fetch documents — How to fetch single documents by id and/or revision
- Fetch views
- Store attachments
- Store documents — How to store documents and objects
Comments (0)
Anonymous replies:
Help Tips
- Text formatting
- Headings
- Lists
Full notation guide*bold*bold_italic_italich1.Large headingh5.Small heading*Bulleted point#Numbered point