couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Couchdb Wiki] Update of "Getting started with Java" by CarlCrowder
Date Fri, 02 Jan 2009 23:40:36 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The following page has been changed by CarlCrowder:
http://wiki.apache.org/couchdb/Getting_started_with_Java

The comment on the change is:
Updating to match newest version of couchdb4j

------------------------------------------------------------------------------
  == Sample Usage ==
  
  {{{
- Session s = new Session("localhost",5984);
+ 		Session s = new Session("localhost",5984);
- Database db = s.getDatabase("foodb");
+ 		Database db = s.getDatabase("foodb");
  
- Document doc = db.getDocument("documentid1234");
+ 		Document doc = db.getDocument("documentid1234");
- doc.put("foo","bar");
+ 		doc.put("foo","bar");
- db.save(doc);
+ 		db.saveDocument(doc);
  
- Document newdoc = new Document();
+ 		Document newdoc = new Document();
- doc.put("foo","baz"); // same as JSON: { foo: "baz"; }
+ 		doc.put("foo","baz"); // same as JSON: { foo: "baz"; }
- db.save(doc); // auto-generated id given by the database
+ 		db.saveDocument(doc); // auto-generated id given by the database
  
- // Running a view
+ 		// Running a view
- ViewResult result = db.getAllDocuments(); // same as db.view("_all_dbs");
+ 		ViewResults result = db.getAllDocuments(); // same as db.view("_all_dbs");
- for (Document d: result.getResults()) {
+ 		for (Document d: result.getResults()) {
-         System.out.println(d.getId());
+ 		        System.out.println(d.getId());
  
-         /*
+ 		        /*
-                 ViewResults may not actually contain the full document, only what the view
+ 		                ViewResults may not actually contain the full document, only what the
view
-                 returned.  So, in order to get the full document, you need to request a
+ 		                returned.  So, in order to get the full document, you need to request
a
-                 new copy from the database.
+ 		                new copy from the database.
-         */
+ 		        */
  
-         Document full = db.getDocument(d.getId());
+ 		        Document full = db.getDocument(d.getId());
- }
+ 		}
  
- // Ad-Hoc view
+ 		// Ad-Hoc view
- ViewResult resultAdHoc = db.adhoc("function (doc) { if (doc.foo=='bar') { return doc; }}");
+ 		ViewResults resultAdHoc = db.adhoc("function (doc) { if (doc.foo=='bar') { return doc;
}}");
  }}}
  
  == Older Libraries ==

Mime
View raw message