Skip to content

tgrall/couchbase-document-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Basement: The simple ODM for Couchbase on Java

Easy way to create an save a document:

Document doc = new Document();
doc.put("first","Tugdual");
doc.put("last","Grall");
doc.put("dob",new Date());

client.save("tug", doc);

This will save a new document associated with the key "tug" :

{
  "_id": "tug",
  "last": "Grall",
  "dob": "Nov 18, 2012 11:45:16 AM",
  "first": "Tugdual"
}

Document with generated ID

Document doc = new Document();
doc.put("first","Tugdual");
doc.put("last","Grall");
doc.put("dob",new Date());

String key = client.save( doc);

Document getDoc = client.getByKey(key);
System.out.println( getDoc.get("first") );
System.out.println( getDoc.get("last") );
System.out.println( getDoc.get("dob") );
System.out.println( getDoc.getKey() );

The stored document looks like :

{
  "_id": "4d0bfa18-040f-4859-8cd8-e904cf8da9b9",
  "last": "Grall",
  "dob": "Nov 18, 2012 11:48:56 AM",
  "first": "Tugdual"
}

About

Simple Java ODM for Couchbase

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages