MutableDocument

A Couchbase Lite Document. A document has key/value properties like a Map.

Constructors

Link copied to clipboard
expect constructor()

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.

expect constructor(id: String?)

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.

expect constructor(data: Map<String, Any?>)

Creates a new Document with a new random UUID and the map as the content. Allowed value types are List, Date, Map, Number, null, String, Array, Blob, and Dictionary. If present, Lists, 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.

expect constructor(id: String?, data: Map<String, Any?>)

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, Date, 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.

expect constructor(id: String?, json: String)

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.

actual constructor()
actual constructor(id: String?)
actual constructor(data: Map<String, Any?>)
actual constructor(id: String?, data: Map<String, Any?>)
actual constructor(id: String?, json: String)
actual constructor()
actual constructor(id: String?)
actual constructor(data: Map<String, Any?>)
actual constructor(id: String?, data: Map<String, Any?>)
actual constructor(id: String?, json: String)

Properties

Link copied to clipboard
open val actual: CPointer<<Error class: unknown class>>
Link copied to clipboard
expect val count: Int

The number of the entries in the dictionary.

actual val count: Int
actual val count: Int
Link copied to clipboard
expect val id: String

The document's ID.

actual val id: String
actual val id: String
Link copied to clipboard
expect val keys: List<String>

A List containing all keys, or an empty List if the document has no properties.

actual val keys: List<String>
actual val keys: List<String>
Link copied to clipboard
expect val revisionID: String?

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.

actual val revisionID: String?
actual val revisionID: String?
Link copied to clipboard
expect val sequence: Long

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 update (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.

actual val sequence: Long
actual val sequence: Long

Functions

Link copied to clipboard
expect operator fun contains(key: String): Boolean

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.

actual operator fun contains(key: String): Boolean
actual operator fun contains(key: String): Boolean
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
operator fun Document.get(key: String): Fragment

Subscript access to a Fragment object by key.

Subscripting access to a MutableFragment object that represents the value of the document by key.

Link copied to clipboard
expect open override fun getArray(key: String): MutableArray?

Get a property's value as an Array, which is a mapping object of an array value. Returns null if the property doesn't exist, or its value is not an array.

actual open override fun getArray(key: String): MutableArray?
actual open override fun getArray(key: String): MutableArray?
Link copied to clipboard
expect fun getBlob(key: String): Blob?

Gets a property's value as a Blob. Returns null if the value doesn't exist, or its value is not a Blob.

actual fun getBlob(key: String): Blob?
open override fun getBlob(key: String): Blob?
Link copied to clipboard
expect fun getBoolean(key: String): Boolean

Gets a property's value as a boolean. Returns true if the value exists, and is either true or a nonzero number.

actual fun getBoolean(key: String): Boolean
actual fun getBoolean(key: String): Boolean
Link copied to clipboard
expect fun getDate(key: String): Instant?

Gets a property's value as a 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.

actual fun getDate(key: String): Instant?
actual fun getDate(key: String): Instant?
Link copied to clipboard
expect open override fun getDictionary(key: String): MutableDictionary?

Get a property's value as a Dictionary, which is a mapping object of a dictionary value. Returns null if the property doesn't exist, or its value is not a dictionary.

actual open override fun getDictionary(key: String): MutableDictionary?
actual open override fun getDictionary(key: String): MutableDictionary?
Link copied to clipboard
expect fun getDouble(key: String): Double

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.

actual fun getDouble(key: String): Double
actual fun getDouble(key: String): Double
Link copied to clipboard
expect fun getFloat(key: String): Float

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.

actual fun getFloat(key: String): Float
actual fun getFloat(key: String): Float
Link copied to clipboard
expect fun getInt(key: String): Int

Gets a property's value as an int. 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.

actual fun getInt(key: String): Int
actual fun getInt(key: String): Int
Link copied to clipboard
expect fun getLong(key: String): Long

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.

actual fun getLong(key: String): Long
actual fun getLong(key: String): Long
Link copied to clipboard
expect fun getNumber(key: String): Number?

Gets a property's value as a Number. Returns null if the value doesn't exist, or its value is not a Number.

actual fun getNumber(key: String): Number?
actual fun getNumber(key: String): Number?
Link copied to clipboard
expect fun getString(key: String): String?

Gets a property's value as a String. Returns null if the value doesn't exist, or its value is not a String.

actual fun getString(key: String): String?
actual fun getString(key: String): String?
Link copied to clipboard
expect fun getValue(key: String): Any?

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.

actual fun getValue(key: String): Any?
open override fun getValue(key: String): Any?
Link copied to clipboard
open override fun hashCode(): Int
open override fun hashCode(): Int
Link copied to clipboard
expect open operator override fun iterator(): Iterator<String>

Gets an iterator over the keys of the document's properties

actual open operator override fun iterator(): Iterator<String>
actual open operator override fun iterator(): Iterator<String>
Link copied to clipboard
expect fun remove(key: String): MutableDocument

Removes the mapping for a key from this Dictionary

actual fun remove(key: String): MutableDocument
actual fun remove(key: String): MutableDocument
Link copied to clipboard
expect fun setArray(key: String, value: Array?): MutableDocument

Set an Array value for the given key

actual fun setArray(key: String, value: Array?): MutableDocument
actual fun setArray(key: String, value: Array?): MutableDocument
Link copied to clipboard
expect fun setBlob(key: String, value: Blob?): MutableDocument

Set a Blob value for the given key

actual fun setBlob(key: String, value: Blob?): MutableDocument
actual fun setBlob(key: String, value: Blob?): MutableDocument
Link copied to clipboard
expect fun setBoolean(key: String, value: Boolean): MutableDocument

Set a boolean value for the given key

actual fun setBoolean(key: String, value: Boolean): MutableDocument
actual fun setBoolean(key: String, value: Boolean): MutableDocument
Link copied to clipboard
expect fun setData(data: Map<String, Any?>): MutableDocument

Populate a document with content from a Map. Allowed value types are List, Date, Map, Number, null, String, Array, Blob, and Dictionary. If present, Lists, 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.

actual fun setData(data: Map<String, Any?>): MutableDocument
actual fun setData(data: Map<String, Any?>): MutableDocument
Link copied to clipboard
expect fun setDate(key: String, value: Instant?): MutableDocument

Set a Date value for the given key

actual fun setDate(key: String, value: Instant?): MutableDocument
actual fun setDate(key: String, value: Instant?): MutableDocument
Link copied to clipboard
expect fun setDictionary(key: String, value: Dictionary?): MutableDocument

Set a Dictionary value for the given key

actual fun setDictionary(key: String, value: Dictionary?): MutableDocument
actual fun setDictionary(key: String, value: Dictionary?): MutableDocument
Link copied to clipboard
expect fun setDouble(key: String, value: Double): MutableDocument

Set a double value for the given key

actual fun setDouble(key: String, value: Double): MutableDocument
actual fun setDouble(key: String, value: Double): MutableDocument
Link copied to clipboard
expect fun setFloat(key: String, value: Float): MutableDocument

Set a float value for the given key

actual fun setFloat(key: String, value: Float): MutableDocument
actual fun setFloat(key: String, value: Float): MutableDocument
Link copied to clipboard
expect fun setInt(key: String, value: Int): MutableDocument

Set an integer value for the given key

actual fun setInt(key: String, value: Int): MutableDocument
actual fun setInt(key: String, value: Int): MutableDocument
Link copied to clipboard
expect fun setJSON(json: String): MutableDocument

Populate a document with content from a JSON string. Allowed value types are List, Date, Map, Number, null, String, Array, Blob, and Dictionary. If present, Lists, 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.

actual fun setJSON(json: String): MutableDocument
actual fun setJSON(json: String): MutableDocument
Link copied to clipboard
expect fun setLong(key: String, value: Long): MutableDocument

Set a long value for the given key

actual fun setLong(key: String, value: Long): MutableDocument
actual fun setLong(key: String, value: Long): MutableDocument
Link copied to clipboard
expect fun setNumber(key: String, value: Number?): MutableDocument

Set a Number value for the given key

actual fun setNumber(key: String, value: Number?): MutableDocument
actual fun setNumber(key: String, value: Number?): MutableDocument
Link copied to clipboard
expect fun setString(key: String, value: String?): MutableDocument

Set a String value for the given key

actual fun setString(key: String, value: String?): MutableDocument
actual fun setString(key: String, value: String?): MutableDocument
Link copied to clipboard
expect fun setValue(key: String, value: Any?): MutableDocument

Set an object value by key. Allowed value types are List, Date, Map, Number, null, String, Array, Blob, and Dictionary. If present, Lists, Maps and Dictionaries may contain only the above types. A Date object will be converted to an ISO-8601 format string.

actual fun setValue(key: String, value: Any?): MutableDocument
actual fun setValue(key: String, value: Any?): MutableDocument
Link copied to clipboard
expect fun toJSON(): String?
actual fun toJSON(): String?
open override fun toJSON(): String?
Link copied to clipboard
expect fun toMap(): Map<String, Any?>

Gets content of the current object as a Map. The values contained in the returned Map object are all JSON based values.

actual fun toMap(): Map<String, Any?>
actual fun toMap(): Map<String, Any?>
Link copied to clipboard
expect open override fun toMutable(): MutableDocument

Returns the copy of this MutableDocument object.

actual open override fun toMutable(): MutableDocument
Link copied to clipboard
open override fun toString(): String
open override fun toString(): String