public class DesignDocumentManager
extends java.lang.Object
// read from javascript design document fileSeeDesignDocument design = DesignDocumentManager.fromFile("../example.js");// read from directory of design documentsList<DesignDocument> design = DesignDocumentManager.fromDirectory("../design-files/");// sync with the databasedb.getDesignDocumentManager().put(designDoc);// sync multiple design documents with the databasedb.getDesignDocumentManager().put(listDesignDocuments);// read from the databaseDesignDocument designDoc2 = db.getDesignDocumentManager().get("_design/example");
Database.getDesignDocumentManager() to access the API.DesignDocument| Modifier and Type | Method and Description |
|---|---|
static java.util.List<DesignDocument> |
fromDirectory(java.io.File directory)
Deserialize a directory of javascript design documents to a List of DesignDocument objects.
|
static DesignDocument |
fromFile(java.io.File file)
Deserialize a javascript design document file to a DesignDocument object.
|
DesignDocument |
get(java.lang.String id)
Gets a design document from the database.
|
DesignDocument |
get(java.lang.String id,
java.lang.String rev)
Gets a design document using the id and revision from the database.
|
void |
put(DesignDocument... designDocs)
Synchronize multiple design documents with the database.
|
Response |
put(DesignDocument document)
Synchronizes a design document to the Database.
|
Response |
remove(DesignDocument designDocument)
Removes a design document using DesignDocument object from the database.
|
Response |
remove(java.lang.String id)
Removes a design document from the database.
|
Response |
remove(java.lang.String id,
java.lang.String rev)
Removes a design document using the id and rev from the database.
|
public Response put(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.
If the design document's ID is not prefixed with _design, then the _design prefix will be added.
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 put(DesignDocument... designDocs)
designDocs - DesignDocument objects to put in the databaseput(DesignDocument)public DesignDocument get(java.lang.String id)
id - the design document id (optionally prefixed with "_design/")DesignDocumentpublic DesignDocument get(java.lang.String id, java.lang.String rev)
id - the document id (optionally prefixed with "_design/")rev - the document revisionDesignDocumentpublic Response remove(java.lang.String id)
id - the document id (optionally prefixed with "_design/")DesignDocumentpublic Response remove(java.lang.String id, java.lang.String rev)
id - the document id (optionally prefixed with "_design/")rev - the document revisionDesignDocumentpublic Response remove(DesignDocument designDocument)
designDocument - the design document object to be removedDesignDocumentpublic static java.util.List<DesignDocument> fromDirectory(java.io.File directory) throws java.io.FileNotFoundException
directory - the directory containing javascript filesDesignDocumentjava.io.FileNotFoundException - if the file does not exist or cannot be readpublic static DesignDocument fromFile(java.io.File file) throws java.io.FileNotFoundException
file - the design document javascript file (UTF-8 encoded)DesignDocumentjava.io.FileNotFoundException - if the file does not exist or cannot be read