MutableDocument
public class MutableDocument : Document, MutableDictionaryProtocol
A mutable version of the Document.
-
Initializes a new MutableDocument object with a new random UUID. The created document will be saved into a database when you call the Database’s save() method with the document object given.
Declaration
Swift
public convenience init()
-
Initializes a new MutableDocument object with the given ID. If a nil ID value is given, 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() method with the document object given.
Declaration
Swift
public convenience init(withID id: String?)
Parameters
id
The document ID.
-
Initializes a new MutableDocument object with a new random UUID and the data. Allowed data value types are Array, ArrayObject, Blob, Date, Dictionary, DictionaryObject, NSNull, Number types, and String. The Arrays and Dictionaries must contain only the above types. The created document will be saved into a database when you call the Database’s save() method with the document object given.
Declaration
Swift
public convenience init(withData data: Dictionary<String, Any>?)
Parameters
data
The data.
-
Initializes a new MutableDocument object with a given ID and the data. If a nil ID value is given, the document will be created with a new random UUID. Allowed data value types are Array, ArrayObject, Blob, Date, Dictionary, DictionaryObject, NSNull, Number types, and String. The Arrays and Dictionaries must contain only the above types. The created document will be saved into a database when you call the Database’s save() method with the document object given.
Declaration
Swift
public convenience init(withID id: String?, data: Dictionary<String, Any>?)
Parameters
id
The document ID.
data
The dictionary object.
-
Returns the same MutableDocument object.
Declaration
Swift
public override func toMutable() -> MutableDocument
Return Value
The MutableDocument object.
-
Set a value for the given key. Allowed value types are Array, Date, Dictionary, Number types, NSNull, String, ArrayObject, Blob, DictionaryObject and nil. The Arrays and Dictionaries must contain only the above types. A nil value will be converted to an NSNull. An Date object will be converted to an ISO-8601 format string.
Declaration
Swift
@discardableResult public func setValue(_ value: Any?, forKey key: String) -> Self
Parameters
value
The value.
key
The key.
Return Value
The self object.
-
Set a String value for the given key.
Declaration
Swift
@discardableResult public func setString(_ value: String?, forKey key: String) -> Self
Parameters
value
The String value.
key
The Document object.
Return Value
The self object.
-
Set an int value for the given key.
Declaration
Swift
@discardableResult public func setInt(_ value: Int, forKey key: String) -> Self
Parameters
value
The int value.
key
The key.
Return Value
The self object.
-
Set an int64 value for the given key.
Declaration
Swift
@discardableResult public func setInt64(_ value: Int64, forKey key: String) -> Self
Parameters
value
The int64 value.
key
The key.
Return Value
The self object.
-
Set a double value for the given key.
Declaration
Swift
@discardableResult public func setDouble(_ value: Double, forKey key: String) -> Self
Parameters
value
The double value.
key
The key.
Return Value
The self object.
-
Set a float value for the given key.
Declaration
Swift
@discardableResult public func setFloat(_ value: Float, forKey key: String) -> Self
Parameters
value
The float value.
key
The key.
Return Value
The self object.
-
Set a boolean value for the given key.
Declaration
Swift
@discardableResult public func setBoolean(_ value: Bool, forKey key: String) -> Self
Parameters
value
The boolean value.
key
The key.
Return Value
The self object.
-
Set a Blob object for the given key. A nil value will be converted to an NSNull.
Declaration
Swift
@discardableResult public func setBlob(_ value: Blob?, forKey key: String) -> Self
Parameters
value
The Blob object
key
The key.
Return Value
The self object.
-
Set a Date object for the given key. A nil value will be converted to an NSNull.
Declaration
Swift
@discardableResult public func setDate(_ value: Date?, forKey key: String) -> Self
Parameters
value
The Date object.
key
The key.
Return Value
The self object.
-
Set an ArrayObject object for the given key. A nil value will be converted to an NSNull.
Declaration
Swift
@discardableResult public func setArray(_ value: ArrayObject?, forKey key: String) -> Self
Parameters
value
The ArrayObject object.
key
The key.
Return Value
The self object.
-
Set a DictionaryObject object for the given key. A nil value will be converted to an NSNull.
Declaration
Swift
@discardableResult public func setDictionary(_ value: DictionaryObject?, forKey key: String) -> Self
Parameters
value
The DictionaryObject object.
key
The key.
Return Value
The self object.
-
Set data for the document. Allowed value types are Array, ArrayObject, Blob, Date, Dictionary, DictionaryObject, NSNull, Number types, and String. The Arrays and Dictionaries must contain only the above types.
Declaration
Swift
@discardableResult public func setData(_ data: Dictionary<String, Any>?) -> Self
Parameters
data
The data.
Return Value
The self object.
-
Removes a given key and its value.
Declaration
Swift
@discardableResult public func removeValue(forKey key: String) -> Self
Parameters
key
The key.
Return Value
The self object.
-
Get a property’s value as an MutableArrayObject, which is a mapping object of an array value. Returns nil if the property doesn’t exists, or its value is not an array.
Declaration
Swift
public override func array(forKey key: String) -> MutableArrayObject?
Parameters
key
The key.
Return Value
The MutableArrayObject object or nil if the property doesn’t exist.
-
Get a property’s value as a MutableDictionaryObject, which is a mapping object of a dictionary value. Returns nil if the property doesn’t exists, or its value is not a dictionary.
Declaration
Swift
public override func dictionary(forKey key: String) -> MutableDictionaryObject?
Parameters
key
The key.
Return Value
The MutableDictionaryObject object or nil if the key doesn’t exist.
-
Subscripting access to a MutableFragment object that represents the value of the dictionary by key.
Declaration
Swift
public override subscript(key: String) -> MutableFragment
Parameters
key
The key.