Store documents
The Document class can be used to create CouchDB documents.
CouchDbClient client = new DefaultCouchDbClient(); Database database = client.getDatabase(DATABASE); Document doc = new Document("the_doc_id"); doc.put("the_date", new Date()); doc.put("list", Arrays.asList(1, 2, 3)); database.saveDocument(doc);
There are other ways to create CouchDB documents though. Simply use a Map for example:
Map<String,Object> doc = new HashMap<String,Object>(); doc.put("the_date", new Date()); doc.put("list", Arrays.asList(1, 2, 3)); database.saveDocument(doc);
Or an arbitrary JSON String:
database.saveDocument("{\"list\": [1,2,3]}");
Or a java.io.Serializable or java.io.Externalizable (TODO).
Add Comment