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.
|
java.util.List<DesignDocument> |
list()
Performs a query to retrieve all the design documents defined in 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 DesignDocument.equals(Object)
. Both the
_rev
value and content must match for the given documents to be considered equal.
This method will not update the revision of the local design 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/")DesignDocument
public DesignDocument get(java.lang.String id, java.lang.String rev)
id
- the document id (optionally prefixed with "_design/")rev
- the document revisionDesignDocument
public Response remove(java.lang.String id)
id
- the document id (optionally prefixed with "_design/")DesignDocument
public Response remove(java.lang.String id, java.lang.String rev)
id
- the document id (optionally prefixed with "_design/")rev
- the document revisionDesignDocument
public Response remove(DesignDocument designDocument)
designDocument
- the design document object to be removedDesignDocument
public java.util.List<DesignDocument> list() throws java.io.IOException
java.io.IOException
- if there was an error communicating with the serverpublic static java.util.List<DesignDocument> fromDirectory(java.io.File directory) throws java.io.FileNotFoundException
directory
- the directory containing javascript filesDesignDocument
java.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)DesignDocument
java.io.FileNotFoundException
- if the file does not exist or cannot be read