ParseOperation

public struct ParseOperation<T> : Savable where T : ParseObject

A ParseOperation represents a modification to a value in a ParseObject. For example, setting, deleting, or incrementing a value are all ParseOperation‘s. ParseOperation themselves can be considered to be immutable.

In most cases, you do not need to create an instance of ParseOperation directly as it can be indirectly created from any ParseObject by using the respective operation property.

  • An operation that sets a field’s value if it has changed from its previous value.

    Note

    Set the value to “nil” if you want it to be “null” on the Parse Server.

    Declaration

    Swift

    public func set<W>(_ key: (String, WritableKeyPath<T, W?>),
                       value: W?) -> Self where W: Encodable

    Parameters

    key

    A tuple consisting of the key and the respective KeyPath of the object.

    value

    The value to set it to.

    Return Value

    The updated operations.

  • An operation that force sets a field’s value.

    Note

    Set the value to “nil” if you want it to be “null” on the Parse Server.

    Declaration

    Swift

    public func forceSet<W>(_ key: (String, WritableKeyPath<T, W?>),
                            value: W?) -> Self where W: Encodable

    Parameters

    key

    A tuple consisting of the key and the respective KeyPath of the object.

    value

    The value to set it to.

    Return Value

    The updated operations.

  • An operation that increases a numeric field’s value by a given amount.

    Declaration

    Swift

    public func increment(_ key: String, by amount: Int) -> ParseOperation<T>

    Parameters

    key

    The key of the object.

    amount

    How much to increment by.

    Return Value

    The updated operations.

  • An operation that adds a new element to an array field, only if it wasn’t already present.

    Declaration

    Swift

    public func addUnique<W>(_ key: String, objects: [W]) -> ParseOperation<T> where W : Encodable, W : Hashable

    Parameters

    key

    The key of the object.

    objects

    The field of objects.

    Return Value

    The updated operations.

  • An operation that adds a new element to an array field, only if it wasn’t already present.

    Declaration

    Swift

    public func addUnique<V>(_ key: (String, WritableKeyPath<T, [V]>),
                             objects: [V]) -> Self where V: Encodable, V: Hashable

    Parameters

    key

    A tuple consisting of the key and the respective KeyPath of the object.

    objects

    The field of objects.

    Return Value

    The updated operations.

  • An operation that adds a new element to an array field, only if it wasn’t already present.

    Declaration

    Swift

    public func addUnique<V>(_ key: (String, WritableKeyPath<T, [V]?>),
                             objects: [V]) -> Self where V: Encodable, V: Hashable

    Parameters

    key

    A tuple consisting of the key and the respective KeyPath of the object.

    objects

    The field of objects.

    Return Value

    The updated operations.

  • An operation that adds a new element to an array field.

    Declaration

    Swift

    public func add<W>(_ key: String, objects: [W]) -> ParseOperation<T> where W : Encodable

    Parameters

    key

    The key of the object.

    objects

    The field of objects.

    Return Value

    The updated operations.

  • An operation that adds a new element to an array field.

    Declaration

    Swift

    public func add<V>(_ key: (String, WritableKeyPath<T, [V]>),
                       objects: [V]) -> Self where V: Encodable

    Parameters

    key

    A tuple consisting of the key and the respective KeyPath of the object.

    objects

    The field of objects.

    Return Value

    The updated operations.

  • An operation that adds a new element to an array field.

    Declaration

    Swift

    public func add<V>(_ key: (String, WritableKeyPath<T, [V]?>),
                       objects: [V]) -> Self where V: Encodable

    Parameters

    key

    A tuple consisting of the key and the respective KeyPath of the object.

    objects

    The field of objects.

    Return Value

    The updated operations.

  • An operation that adds a new relation to an array field.

    Declaration

    Swift

    public func addRelation<W>(_ key: String, objects: [W]) throws -> ParseOperation<T> where W : ParseObject

    Parameters

    key

    The key of the object.

    objects

    The field of objects.

    Return Value

    The updated operations.

  • An operation that adds a new relation to an array field.

    Declaration

    Swift

    public func addRelation<V>(_ key: (String, WritableKeyPath<T, [V]>),
                               objects: [V]) throws -> Self where V: ParseObject

    Parameters

    key

    A tuple consisting of the key and the respective KeyPath of the object.

    objects

    The field of objects.

    Return Value

    The updated operations.

  • An operation that adds a new relation to an array field.

    Declaration

    Swift

    public func addRelation<V>(_ key: (String, WritableKeyPath<T, [V]?>),
                               objects: [V]) throws -> Self where V: ParseObject

    Parameters

    key

    A tuple consisting of the key and the respective KeyPath of the object.

    objects

    The field of objects.

    Return Value

    The updated operations.

  • An operation that removes every instance of an element from an array field.

    Declaration

    Swift

    public func remove<W>(_ key: String, objects: [W]) -> ParseOperation<T> where W : Encodable

    Parameters

    key

    The key of the object.

    objects

    The field of objects.

    Return Value

    The updated operations.

  • An operation that removes every instance of an element from an array field.

    Declaration

    Swift

    public func remove<V>(_ key: (String, WritableKeyPath<T, [V]>),
                          objects: [V]) -> Self where V: Encodable, V: Hashable

    Parameters

    key

    A tuple consisting of the key and the respective KeyPath of the object.

    objects

    The field of objects.

    Return Value

    The updated operations.

  • An operation that removes every instance of an element from an array field.

    Declaration

    Swift

    public func remove<V>(_ key: (String, WritableKeyPath<T, [V]?>),
                          objects: [V]) -> Self where V: Encodable, V: Hashable

    Parameters

    key

    A tuple consisting of the key and the respective KeyPath of the object.

    objects

    The field of objects.

    Return Value

    The updated operations.

  • An operation that removes every instance of a relation from an array field.

    Declaration

    Swift

    public func removeRelation<W>(_ key: String, objects: [W]) throws -> ParseOperation<T> where W : ParseObject

    Parameters

    key

    The key of the object.

    objects

    The field of objects.

    Return Value

    The updated operations.

  • An operation that removes every instance of a relation from an array field.

    Declaration

    Swift

    public func removeRelation<V>(_ key: (String, WritableKeyPath<T, [V]>),
                                  objects: [V]) throws -> Self where V: ParseObject

    Parameters

    key

    A tuple consisting of the key and the respective KeyPath of the object.

    objects

    The field of objects.

    Return Value

    The updated operations.

  • An operation that removes every instance of a relation from an array field.

    Declaration

    Swift

    public func removeRelation<V>(_ key: (String, WritableKeyPath<T, [V]?>),
                                  objects: [V]) throws -> Self where V: ParseObject

    Parameters

    key

    A tuple consisting of the key and the respective KeyPath of the object.

    objects

    The field of objects.

    Return Value

    The updated operations.

  • An operation where a field is deleted from the object.

    Declaration

    Swift

    public func unset(_ key: String) -> ParseOperation<T>

    Parameters

    key

    The key of the object.

    Return Value

    The updated operations.

  • An operation where a field is deleted from the object.

    Declaration

    Swift

    public func unset<V>(_ key: (String, WritableKeyPath<T, V?>)) -> ParseOperation<T> where V : Encodable

    Parameters

    key

    A tuple consisting of the key and the respective KeyPath of the object.

    Return Value

    The updated operations.

  • Declaration

    Swift

    public func encode(to encoder: Encoder) throws

Async/Await

  • save(options:) Asynchronous

    Saves the operations on the ParseObject asynchronously and executes the given callback block.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    func save(options: API.Options = []) async throws -> T

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A saved ParseFile.

Combine

  • Saves the operations on the ParseObject asynchronously and executes the given callback block.

    Declaration

    Swift

    func savePublisher(options: API.Options = []) -> Future<T, ParseError>

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

Savable

  • Saves the operations on the ParseObject synchronously and throws an error if there’s an issue.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    public func save(options: API.Options = []) throws -> T

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns saved ParseObject.

  • Saves the operations on the ParseObject asynchronously and executes the given callback block.

    Declaration

    Swift

    public func save(
        options: API.Options = [],
        callbackQueue: DispatchQueue = .main,
        completion: @escaping (Result<T, ParseError>) -> Void
    )

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<T, ParseError>).