public class Document
extends com.cloudant.client.org.lightcouch.Document
Base class for serialisation and deserialisation of Cloudant Documents.
This class and its subclasses serve the following purposes:
_all_docs
and views
This class or its subclasses can also be used for APIs like
Database.find(Class, String)
where deserialisation is performed,
but it is useful to retain fields such as _id
, _rev
, _deleted
for
subsequent operations.
Because this class only represents a "skeleton" document, users should consider sub-classing
Document
in order to map other fields, for example:
import com.cloudant.client.api.model.Document;
public class EmployeeDocument extends Document {
String firstName;
String lastName;
// etc
}
Note that the normal
Gson
serialisation rules apply and that annotations like SerializedName
can be used.
Important:Top-level field names that begin with the underscore character (_) are
reserved in Cloudant and must not be used. If fine-grained control of reserved properties
such as _id
, _rev
, _deleted
is required, then they should be mapped to
fields in a custom class which does not subclass Document
.
Constructor and Description |
---|
Document() |
Modifier and Type | Method and Description |
---|---|
void |
addAttachment(java.lang.String name,
Attachment attachment) |
public void addAttachment(java.lang.String name, Attachment attachment)