Class CouchDbDesign

java.lang.Object
org.lightcouch.CouchDbDesign

public class CouchDbDesign extends Object
Provides 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
Author:
Ahmed Yehia
See Also:
  • Method Details

    • 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:
      Response 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.
    • synchronizeAllWithDb

      public void synchronizeAllWithDb()
      Synchronize all design documents on desk to the database.
      See Also:
    • getFromDb

      public DesignDocument getFromDb(String id)
      Gets a design document from the database.
      Parameters:
      id - The document id
      Returns:
      DesignDocument
    • getFromDb

      public DesignDocument getFromDb(String id, String rev)
      Gets a design document from the database.
      Parameters:
      id - The document id
      rev - The document revision
      Returns:
      DesignDocument
    • getAllFromDesk

      public List<DesignDocument> getAllFromDesk()
      Gets all design documents from desk.
      Returns:
      a list of all design documents
      See Also:
    • getFromDesk

      public DesignDocument getFromDesk(String id)
      Gets a design document from desk.
      Parameters:
      id - The document id to get.
      Returns:
      DesignDocument
    • readContent

      public String readContent(List<String> elements, String rootPath, String element)