Skip to end of metadata
Go to start of metadata

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).

Labels

todo todo Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.