public class CouchDbDesign
extends java.lang.Object
// read from system files
DesignDocument design1 = dbClient.design().getFromDesk("example");
// sync with the database
dbClient.design().synchronizeWithDb(design1);
// sync all with the database
dbClient.syncDesignDocsWithDb();
// read from the database
DesignDocument design2 = dbClient.design().getFromDb("_design/example");
CouchDbClient#design() dbClient.design()} to access the API.,
DesignDocument| Modifier and Type | Field and Description |
|---|---|
private CouchDbClientBase |
dbc |
private static java.lang.String |
DESIGN_DOCS_DIR |
private static java.lang.String |
DESIGN_PREFIX |
private static java.lang.String |
FILTERS |
private static java.lang.String |
FULLTEXT |
private static java.lang.String |
INDEXES |
private static java.lang.String |
JAVASCRIPT |
private static java.lang.String |
LISTS |
private static java.lang.String |
MAP_JS |
private static java.lang.String |
REDUCE_JS |
private static java.lang.String |
REWRITES |
private static java.lang.String |
SHOWS |
private static java.lang.String |
UPDATES |
private static java.lang.String |
VALIDATE_DOC |
private static java.lang.String |
VIEWS |
| Constructor and Description |
|---|
CouchDbDesign(CouchDbClientBase dbc) |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<DesignDocument> |
getAllFromDesk()
Gets all design documents from desk.
|
DesignDocument |
getFromDb(java.lang.String id)
Gets a design document from the database.
|
DesignDocument |
getFromDb(java.lang.String id,
java.lang.String rev)
Gets a design document from the database.
|
DesignDocument |
getFromDesk(java.lang.String id)
Gets a design document from desk.
|
private java.util.Map<java.lang.String,java.lang.String> |
populateMap(java.lang.String rootPath,
java.util.List<java.lang.String> elements,
java.lang.String element) |
java.lang.String |
readContent(java.util.List<java.lang.String> elements,
java.lang.String rootPath,
java.lang.String element) |
void |
synchronizeAllWithDb()
Synchronize all design documents on desk to the database.
|
Response |
synchronizeWithDb(DesignDocument document)
Synchronizes a design document to the Database.
|
private static final java.lang.String DESIGN_DOCS_DIR
private static final java.lang.String JAVASCRIPT
private static final java.lang.String DESIGN_PREFIX
private static final java.lang.String VALIDATE_DOC
private static final java.lang.String VIEWS
private static final java.lang.String FILTERS
private static final java.lang.String SHOWS
private static final java.lang.String LISTS
private static final java.lang.String UPDATES
private static final java.lang.String REWRITES
private static final java.lang.String FULLTEXT
private static final java.lang.String INDEXES
private static final java.lang.String MAP_JS
private static final java.lang.String REDUCE_JS
private CouchDbClientBase dbc
CouchDbDesign(CouchDbClientBase dbc)
public Response synchronizeWithDb(DesignDocument document)
This method will first try to find a document in the database with the same id as the given document, if it is not found then the given document will be saved to the database.
If the document was found in the database, it will be compared with the given document using
equals(). If both documents are not equal, then the given document will be saved to the
database and updates the existing document.
document - The design document to synchronizeResponse as a result of a document save or update, or returns null if no
action was taken and the document in the database is up-to-date with the given document.public void synchronizeAllWithDb()
public DesignDocument getFromDb(java.lang.String id)
id - The document idDesignDocumentpublic DesignDocument getFromDb(java.lang.String id, java.lang.String rev)
id - The document idrev - The document revisionDesignDocumentpublic java.util.List<DesignDocument> getAllFromDesk()
getFromDesk(String)public DesignDocument getFromDesk(java.lang.String id)
id - The document id to get.DesignDocumentprivate java.util.Map<java.lang.String,java.lang.String> populateMap(java.lang.String rootPath,
java.util.List<java.lang.String> elements,
java.lang.String element)
public java.lang.String readContent(java.util.List<java.lang.String> elements,
java.lang.String rootPath,
java.lang.String element)