MutableDocument
A Couchbase Lite Document. A document has key/value properties like a Map.
Constructors
Creates a new Document object with a new random UUID. The created document will be saved into a database when you call the Database's save(Document) method with the document object given.
Creates a new Document with the given ID. If the id is null, the document will be created with a new random UUID. The created document will be saved into a database when you call the Database's save(Document) method with the document object given.
Creates a new Document with a new random UUID and the map as the content. Allowed value types are List, Instant, Map, Number, null, String, Array, Blob, and Dictionary. If present, Lists, Arrays, Maps and Dictionaries may contain only the above types. The created document will be saved into a database when you call Database.save(Document) with this document object.
Creates a new Document with a given ID and content from the passed Map. If the id is null, the document will be created with a new random UUID. Allowed value types are List, Instant, Map, Number, null, String, Array, Blob, and Dictionary. The List and Map must contain only the above types. The created document will be saved into a database when you call the Database's save(Document) method with the document object given.
Creates a new Document with the given ID and content from the passed JSON string. If the id is null, the document will be created with a new random UUID. The created document will be saved into a database when you call the Database's save(Document) method with the document object given.
Properties
The collection to which the document belongs.
The document's revision id. The revision id in the Document class is a constant while the revision id in the MutableDocument class is not. A newly created Document will have a null revision id. The revision id in a MutableDocument will be updated on save. The revision id format is opaque, which means its format has no meaning and shouldn't be parsed to get information.
The sequence number of the document in the database. The sequence number indicates how recently the document has been changed. Every time a document is updated, the database assigns it the next sequential sequence number. Thus, when a document's sequence number changes it means that the document been updated (on-disk). If one document's sequence is different than another's, the document with the larger sequence number was changed more recently. Sequence numbers are not available for documents obtained from a replication filter. This method will always return 0 for such documents.
Functions
Tests whether a property exists or not. This can be less expensive than getValue(String), because it does not have to allocate an Object for the property value.
Subscript access to a Fragment object by key.
Subscripting access to a MutableFragment object that represents the value of the document by key.
Get a property's value as an Array. Returns null if the property doesn't exist, or its value is not an array.
Gets a property's value as a boolean. Returns true if the value exists, and is either true
or a nonzero number.
Gets a property's value as an Instant date. JSON does not directly support dates, so the actual property value must be a string, which is then parsed according to the ISO-8601 date format (the default used in JSON.) Returns null if the value doesn't exist, is not a string, or is not parsable as a date. NOTE: This is not a generic date parser! It only recognizes the ISO-8601 format, with or without milliseconds.
Get a property's value as a Dictionary. Returns null if the property doesn't exist, or its value is not a dictionary.
Gets a property's value as a double. Integers will be converted to double. The value true
is returned as 1.0, false
as 0.0. Returns 0.0 if the property doesn't exist or does not have a numeric value.
Gets a property's value as a float. Integers will be converted to float. The value true
is returned as 1.0, false
as 0.0. Returns 0.0 if the value doesn't exist or does not have a numeric value.
Gets a property's value as a long. Floating point values will be rounded. The value true
is returned as 1, false
as 0. Returns 0 if the value doesn't exist or does not have a numeric value.
Gets a property's value as an object. The object types are Blob, Array, Dictionary, Number, or String based on the underlying data type; or nil if the property value is null or the property doesn't exist.
Removes the mapping for a key from this Dictionary
Set an Array value for the given key
Set a Blob value for the given key
Set a boolean value for the given key
Populate a document with content from a Map. Allowed value types are List, Instant, Map, Number, null, String, Array, Blob, and Dictionary. If present, Lists, Arrays, Maps and Dictionaries may contain only the above types. Setting the document content will replace the current data including the existing Array and Dictionary objects.
Set an Instant date value for the given key
Set a Dictionary value for the given key
Set a double value for the given key
Set a float value for the given key
Set an integer value for the given key
Populate a document with content from a JSON string. Allowed value types are List, Instant, Map, Number, null, String, Array, Blob, and Dictionary. If present, Lists, Arrays, Maps and Dictionaries may contain only the above types. Setting the document content will replace the current data including the existing Array and Dictionary objects.
Set a long value for the given key
Set a Number value for the given key
Set a String value for the given key
Set an object value by key. Allowed value types are List, Instant, Map, Number, null, String, Array, Blob, and Dictionary. If present, Lists, Arrays, Maps and Dictionaries may contain only the above types. An Instant date object will be converted to an ISO-8601 format string.
Returns the copy of this MutableDocument object.