Package org.lightcouch
Class CouchDbDesign
- java.lang.Object
-
- org.lightcouch.CouchDbDesign
-
public class CouchDbDesign extends java.lang.ObjectProvides API to work with design documents.Usage Example:
// 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");- Since:
- 0.0.2
- See Also:
DesignDocument
-
-
Field Summary
Fields Modifier and Type Field Description private CouchDbClientBasedbcprivate static java.lang.StringDESIGN_DOCS_DIRprivate static java.lang.StringDESIGN_PREFIXprivate static java.lang.StringFILTERSprivate static java.lang.StringFULLTEXTprivate static java.lang.StringINDEXESprivate static java.lang.StringJAVASCRIPTprivate static java.lang.StringLISTSprivate static java.lang.StringMAP_JSprivate static java.lang.StringREDUCE_JSprivate static java.lang.StringREWRITESprivate static java.lang.StringSHOWSprivate static java.lang.StringUPDATESprivate static java.lang.StringVALIDATE_DOCprivate static java.lang.StringVIEWS
-
Constructor Summary
Constructors Constructor Description CouchDbDesign(CouchDbClientBase dbc)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<DesignDocument>getAllFromDesk()Gets all design documents from desk.DesignDocumentgetFromDb(java.lang.String id)Gets a design document from the database.DesignDocumentgetFromDb(java.lang.String id, java.lang.String rev)Gets a design document from the database.DesignDocumentgetFromDesk(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.StringreadContent(java.util.List<java.lang.String> elements, java.lang.String rootPath, java.lang.String element)voidsynchronizeAllWithDb()Synchronize all design documents on desk to the database.ResponsesynchronizeWithDb(DesignDocument document)Synchronizes a design document to the Database.
-
-
-
Field Detail
-
DESIGN_DOCS_DIR
private static final java.lang.String DESIGN_DOCS_DIR
- See Also:
- Constant Field Values
-
JAVASCRIPT
private static final java.lang.String JAVASCRIPT
- See Also:
- Constant Field Values
-
DESIGN_PREFIX
private static final java.lang.String DESIGN_PREFIX
- See Also:
- Constant Field Values
-
VALIDATE_DOC
private static final java.lang.String VALIDATE_DOC
- See Also:
- Constant Field Values
-
VIEWS
private static final java.lang.String VIEWS
- See Also:
- Constant Field Values
-
FILTERS
private static final java.lang.String FILTERS
- See Also:
- Constant Field Values
-
SHOWS
private static final java.lang.String SHOWS
- See Also:
- Constant Field Values
-
LISTS
private static final java.lang.String LISTS
- See Also:
- Constant Field Values
-
UPDATES
private static final java.lang.String UPDATES
- See Also:
- Constant Field Values
-
REWRITES
private static final java.lang.String REWRITES
- See Also:
- Constant Field Values
-
FULLTEXT
private static final java.lang.String FULLTEXT
- See Also:
- Constant Field Values
-
INDEXES
private static final java.lang.String INDEXES
- See Also:
- Constant Field Values
-
MAP_JS
private static final java.lang.String MAP_JS
- See Also:
- Constant Field Values
-
REDUCE_JS
private static final java.lang.String REDUCE_JS
- See Also:
- Constant Field Values
-
dbc
private CouchDbClientBase dbc
-
-
Constructor Detail
-
CouchDbDesign
CouchDbDesign(CouchDbClientBase dbc)
-
-
Method Detail
-
synchronizeWithDb
public Response synchronizeWithDb(DesignDocument document)
Synchronizes a design document to the Database.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.- Parameters:
document- The design document to synchronize- Returns:
Responseas a result of a document save or update, or returnsnullif no action was taken and the document in the database is up-to-date with the given document.
-
synchronizeAllWithDb
public void synchronizeAllWithDb()
Synchronize all design documents on desk to the database.
-
getFromDb
public DesignDocument getFromDb(java.lang.String id)
Gets a design document from the database.- Parameters:
id- The document id- Returns:
DesignDocument
-
getFromDb
public DesignDocument getFromDb(java.lang.String id, java.lang.String rev)
Gets a design document from the database.- Parameters:
id- The document idrev- The document revision- Returns:
DesignDocument
-
getAllFromDesk
public java.util.List<DesignDocument> getAllFromDesk()
Gets all design documents from desk.- Returns:
- a list of all design documents
- See Also:
getFromDesk(String)
-
getFromDesk
public DesignDocument getFromDesk(java.lang.String id)
Gets a design document from desk.- Parameters:
id- The document id to get.- Returns:
DesignDocument
-
populateMap
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)
-
readContent
public java.lang.String readContent(java.util.List<java.lang.String> elements, java.lang.String rootPath, java.lang.String element)
-
-