|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.fourspaces.couchdb.Database
public class Database
This represents a particular database on the CouchDB server
Using this object, you can get/create/update/delete documents. You can also call views (named and adhoc) to query the underlying database.
Method Summary | |
---|---|
ViewResults |
adhoc(AdHocView view)
Runs an ad-hoc view from an AdHocView object. |
ViewResults |
adhoc(String function)
Runs an ad-hoc view from a string |
void |
bulkSaveDocuments(Document[] documents)
|
boolean |
deleteDocument(Document d)
Deletes a document |
ViewResults |
getAllDocuments()
Runs the standard "_all_docs" view on this database |
ViewResults |
getAllDocuments(int revision)
Runs "_all_docs_by_update_seq?startkey=revision" view on this database |
ViewResults |
getAllDocumentsWithCount(int count)
Runs the standard "_all_docs" view on this database, with count |
Document |
getDocument(String id)
Retrieves a document from the CouchDB database |
Document |
getDocument(String id,
String revision)
Retrieves a specific document revision |
Document |
getDocument(String id,
String revision,
boolean showRevisions)
Retrieves a specific document revision and (optionally) asks for a list of all revisions |
int |
getDocumentCount()
The number of documents in the database at the time that it was retrieved from the session This number probably isn't accurate after the initial load... |
Document |
getDocumentWithRevisions(String id)
Retrieves a document from the database and asks for a list of it's revisions. |
String |
getName()
The name of the database |
int |
getUpdateSeq()
The update seq from the initial database load. |
void |
saveDocument(Document doc)
Save a document w/o specifying an id (can be null) |
void |
saveDocument(Document doc,
String docId)
Save a document at the given _id |
ViewResults |
view(String fullname)
Runs a named view Not currently working in CouchDB code |
ViewResults |
view(View view)
Runs a named view on the database This will run a view and apply any filtering that is requested (reverse, startkey, etc). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public String getName()
public int getDocumentCount()
public int getUpdateSeq()
getAllDocuments()
public ViewResults getAllDocuments()
public ViewResults getAllDocumentsWithCount(int count)
public ViewResults getAllDocuments(int revision)
public ViewResults view(View view)
view
-
public ViewResults view(String fullname)
name
- - the fullname (including the document name) ex: foodoc:viewname
public ViewResults adhoc(String function)
function
- - the Javascript function to use as the filter.
public ViewResults adhoc(AdHocView view)
view
-
public void saveDocument(Document doc, String docId) throws IOException
if the docId is null or empty, then this performs a POST to the database and retrieves a new _id.
Otherwise, a PUT is called.
Either way, a new _id and _rev are retrieved and updated in the Document object
doc
- docId
-
IOException
public void saveDocument(Document doc) throws IOException
doc
-
IOException
public void bulkSaveDocuments(Document[] documents) throws IOException
IOException
public Document getDocument(String id) throws IOException
id
-
IOException
public Document getDocumentWithRevisions(String id) throws IOException
id
-
IOException
public Document getDocument(String id, String revision) throws IOException
id
- revision
-
IOException
public Document getDocument(String id, String revision, boolean showRevisions) throws IOException
id
- revision
- showRevisions
-
IOException
public boolean deleteDocument(Document d) throws IOException
d
-
IllegalArgumentException
- for blank document id
IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |