|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface CouchDbConnector
Primary interface for working with Objects mapped as documents in CouchDb. The Id and revision of mapped Objects must be accessible by org.ektorp.util.Documents class.
Method Summary | ||
---|---|---|
String |
callUpdateHandler(String designDocID,
String function,
String docId)
|
|
String |
callUpdateHandler(String designDocID,
String function,
String docId,
Map<String,String> params)
|
|
String |
callUpdateHandler(UpdateHandlerRequest req)
|
|
|
callUpdateHandler(UpdateHandlerRequest req,
Class<T> c)
|
|
List<DocumentChange> |
changes(ChangesCommand cmd)
Queries the database for changes. |
|
StreamingChangesResult |
changesAsStream(ChangesCommand cmd)
Queries the database for changes. this operation gives you the result as a iterable stream of documentchange objects, the stream should be closed when finished |
|
ChangesFeed |
changesFeed(ChangesCommand cmd)
Sets up a continuous changes feed. |
|
void |
cleanupViews()
View indexes on disk are named after their MD5 hash of the view definition. |
|
void |
compact()
Compaction compresses the database file by removing unused sections created during updates. |
|
void |
compactViews(String designDocumentId)
This compacts the view index from the current version of the design document. |
|
boolean |
contains(String id)
Check if the database contains a document. |
|
String |
copy(String sourceDocId,
String targetDocId)
Copies a document to the target document id. |
|
String |
copy(String sourceDocId,
String targetDocId,
String targetRevision)
Copies a document and overwrites the target document. |
|
void |
create(Object o)
Creates the Object as a document in the database. |
|
void |
create(String id,
Object o)
|
|
String |
createAttachment(String docId,
AttachmentInputStream data)
Creates both the document and the attachment |
|
String |
createAttachment(String docId,
String revision,
AttachmentInputStream data)
Adds an attachment to the specified document id. |
|
void |
createDatabaseIfNotExists()
Creates a database on the configured path if it does not exists. |
|
String |
delete(Object o)
Deletes the Object in the database. |
|
String |
delete(String id,
String revision)
Deletes the document in the database. |
|
String |
deleteAttachment(String docId,
String revision,
String attachmentId)
|
|
void |
ensureFullCommit()
Commits any recent changes to the specified database to disk. |
|
List<DocumentOperationResult> |
executeAllOrNothing(Collection<?> objects)
Creates, updates or deletes all objects in the supplied collection. |
|
List<DocumentOperationResult> |
executeAllOrNothing(InputStream inputStream)
Creates, updates or deletes all objects in the supplied collection. |
|
List<DocumentOperationResult> |
executeBulk(Collection<?> objects)
Creates, updates or deletes all objects in the supplied collection. |
|
List<DocumentOperationResult> |
executeBulk(InputStream inputStream)
Creates, updates or deletes all objects in the supplied collection. |
|
|
find(Class<T> c,
String id)
Same as get(Class |
|
|
find(Class<T> c,
String id,
Options options)
Same as get(Class |
|
|
get(Class<T> c,
String id)
|
|
|
get(Class<T> c,
String id,
Options options)
|
|
|
get(Class<T> c,
String id,
String rev)
Deprecated. use get(Class |
|
List<String> |
getAllDocIds()
|
|
InputStream |
getAsStream(String id)
Please note that the stream has to be closed after usage, otherwise http connection leaks will occur and the system will eventually hang due to connection starvation. |
|
InputStream |
getAsStream(String id,
Options options)
Please note that the stream has to be closed after usage, otherwise http connection leaks will occur and the system will eventually hang due to connection starvation. |
|
InputStream |
getAsStream(String id,
String rev)
Deprecated. use getAsStream(String id, Options options) |
|
AttachmentInputStream |
getAttachment(String id,
String attachmentId)
Reads an attachment from the database. |
|
AttachmentInputStream |
getAttachment(String id,
String attachmentId,
String revision)
|
|
HttpClient |
getConnection()
Convenience method for accessing the underlying HttpClient. |
|
String |
getCurrentRevision(String id)
Obtain the current revision of a document using a lightweight request. |
|
String |
getDatabaseName()
|
|
DbInfo |
getDbInfo()
Provides meta information about this database. |
|
DesignDocInfo |
getDesignDocInfo(String designDocId)
Obtains information about a given design document, including the index, index size and current status of the design document and associated index information. |
|
int |
getRevisionLimit()
Revision limit defines a upper bound of document revisions which CouchDB keeps track of |
|
List<Revision> |
getRevisions(String id)
|
|
Security |
getSecurity()
Provides access to the database's underlying security configuration |
|
|
getWithConflicts(Class<T> c,
String id)
Deprecated. use get(Class |
|
String |
path()
|
|
PurgeResult |
purge(Map<String,List<String>> revisionsToPurge)
Permanently removes the references to deleted documents from the database. |
|
|
queryForPage(ViewQuery query,
PageRequest pr,
Class<T> type)
Provides paged view results. |
|
InputStream |
queryForStream(ViewQuery query)
|
|
StreamingViewResult |
queryForStreamingView(ViewQuery query)
Please note that the StreamingViewResult need to be closed after usage. |
|
ViewResult |
queryView(ViewQuery query)
|
|
|
queryView(ViewQuery query,
Class<T> type)
This method requires the view result values to be document ids or documents : If the value is a document id, then the document is fetched from couchDB. |
|
ReplicationStatus |
replicateFrom(String source)
Replicate the content in the source database into this database. |
|
ReplicationStatus |
replicateFrom(String source,
Collection<String> docIds)
Replicate the content in the source database into this database. |
|
ReplicationStatus |
replicateTo(String target)
Replicate the content in this database into the specified target database. |
|
ReplicationStatus |
replicateTo(String target,
Collection<String> docIds)
Replicate the content in this database into the specified target database. |
|
void |
setRevisionLimit(int limit)
|
|
void |
update(Object o)
Updates the document. |
|
void |
update(String id,
InputStream document,
long length,
Options options)
Sends a document to the Couch server as a JSON stream |
|
void |
updateMultipart(String id,
InputStream stream,
String boundary,
long length,
Options options)
Sends a document to the Couch server as a MIME multipart/related message. |
|
Status |
updateSecurity(Security security)
Provides a way to update the database's underlying security configuration |
Methods inherited from interface org.ektorp.LocalBulkBuffer |
---|
addToBulkBuffer, clearBulkBuffer, flushBulkBuffer |
Method Detail |
---|
void create(String id, Object o)
id
- the
- object to store in the database
UpdateConflictException
- if there was an update conflict.void create(Object o)
o
-
UpdateConflictException
- if there was an update conflict.void update(Object o)
o
-
UpdateConflictException
- if there was an update conflict.String delete(Object o)
o
-
UpdateConflictException
- if there was an update conflict.String delete(String id, String revision)
id
- revision
-
UpdateConflictException
- if there was an update conflict.String copy(String sourceDocId, String targetDocId)
sourceDocId
- targetDocId
-
String copy(String sourceDocId, String targetDocId, String targetRevision)
sourceDocId
- targetDocId
- targetRevision
-
PurgeResult purge(Map<String,List<String>> revisionsToPurge)
revisionsToPurge
- document IDs & revisions to be purged
<T> T get(Class<T> c, String id)
T
- c
- the target class to map to.id
- the id of the document in the database.
DocumentNotFoundException
- if the document was not found.<T> T get(Class<T> c, String id, Options options)
c
- the target class to map to.id
- the id of the document in the database.options
-
DocumentNotFoundException
- if the document was not found.<T> T find(Class<T> c, String id)
c
- id
-
<T> T find(Class<T> c, String id, Options options)
c
- id
- options
-
@Deprecated <T> T get(Class<T> c, String id, String rev)
T
- c
- the target class to map to.id
- the id of the document in the database.rev
- of the object.
DocumentNotFoundException
- if the document was not found.@Deprecated <T> T getWithConflicts(Class<T> c, String id)
T
- c
- the target class to map to.id
- the id of the document in the database.
DocumentNotFoundException
- if the document was not found.boolean contains(String id)
id
-
InputStream getAsStream(String id)
id
-
DocumentNotFoundException
- if the document was not found.@Deprecated InputStream getAsStream(String id, String rev)
id
- rev
-
DocumentNotFoundException
- if the document was not found.InputStream getAsStream(String id, Options options)
id
- options
-
DocumentNotFoundException
- if the document was not found.List<Revision> getRevisions(String id)
id
-
DocumentNotFoundException
- if the document was not found.String getCurrentRevision(String id)
id
-
DocumentNotFoundException
- if the document was not found.AttachmentInputStream getAttachment(String id, String attachmentId)
id
- attachmentId
-
DocumentNotFoundException
- if the document was not found.AttachmentInputStream getAttachment(String id, String attachmentId, String revision)
String createAttachment(String docId, AttachmentInputStream data)
docId
- a
- - the data to be saved as an attachment
UpdateConflictException
- if there was an update conflict.String createAttachment(String docId, String revision, AttachmentInputStream data)
docId
- revision
- a
- - the data to be saved as an attachment
UpdateConflictException
- if there was an update conflict.String deleteAttachment(String docId, String revision, String attachmentId)
docId
- revision
- attachmentId
-
UpdateConflictException
- if there was an update conflict.List<String> getAllDocIds()
<T> List<T> queryView(ViewQuery query, Class<T> type)
T
- query
- type
- the type to map the result to
<T> Page<T> queryForPage(ViewQuery query, PageRequest pr, Class<T> type)
query
- pr
- type
-
ViewResult queryView(ViewQuery query)
query
-
StreamingViewResult queryForStreamingView(ViewQuery query)
query
-
InputStream queryForStream(ViewQuery query)
query
-
void createDatabaseIfNotExists()
String getDatabaseName()
String path()
HttpClient getConnection()
DbInfo getDbInfo()
Security getSecurity()
Security
Status updateSecurity(Security security)
security
- the Security
to update
Status
DesignDocInfo getDesignDocInfo(String designDocId)
designDocId
-
void compact()
void compactViews(String designDocumentId)
designDocumentId
- void cleanupViews()
int getRevisionLimit()
void setRevisionLimit(int limit)
ReplicationStatus replicateFrom(String source)
source
- database
ReplicationStatus replicateFrom(String source, Collection<String> docIds)
source
- databasedocIds
-
ReplicationStatus replicateTo(String target)
target
- database
ReplicationStatus replicateTo(String target, Collection<String> docIds)
target
- databasedocIds
-
List<DocumentOperationResult> executeBulk(InputStream inputStream)
an
- json array with documents ex [{"_id":"1", "name": "hello world" }, "_id":"2", "name": "hello world 2"}]
List<DocumentOperationResult> executeAllOrNothing(InputStream inputStream)
an
- json array with documents
List<DocumentOperationResult> executeBulk(Collection<?> objects)
objects
- , all objects will have their id and revision set.
List<DocumentOperationResult> executeAllOrNothing(Collection<?> objects)
objects
- , all objects will have their id and revision set.
List<DocumentChange> changes(ChangesCommand cmd)
cmd
-
StreamingChangesResult changesAsStream(ChangesCommand cmd)
cmd
-
ChangesFeed changesFeed(ChangesCommand cmd)
cmd
-
String callUpdateHandler(String designDocID, String function, String docId)
designDoc
- function
- docId
-
String callUpdateHandler(String designDocID, String function, String docId, Map<String,String> params)
designDoc
- function
- docId
- params
-
<T> T callUpdateHandler(UpdateHandlerRequest req, Class<T> c)
String callUpdateHandler(UpdateHandlerRequest req)
void ensureFullCommit()
void updateMultipart(String id, InputStream stream, String boundary, long length, Options options)
id
- the document IDstream
- an InputStream of the multipart message containing
the document and any attachmentsboundary
- the boundary of the multipart/related message partslength
- the length of the MIME multipart message streamoptions
- options to pass to the Couch requestvoid update(String id, InputStream document, long length, Options options)
id
- the document IDdocument
- an InputStream of the JSON documentlength
- the length of the JSON documentoptions
- options to pass to the Couch request
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |