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 should not call this class directly as a ParseOperation can be indirectly created from any ParseObject by using its operation property.

  • 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.

  • 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.

  • 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]) throws -> Self where V: Encodable, V: Hashable

    Parameters

    key

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

    objects

    The field of objects.

  • 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]) throws -> Self where V: Encodable, V: Hashable

    Parameters

    key

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

    objects

    The field of objects.

  • 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.

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

    Declaration

    Swift

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

    Parameters

    key

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

    objects

    The field of objects.

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

    Declaration

    Swift

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

    Parameters

    key

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

    objects

    The field of objects.

  • 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.

  • 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 KeyPath of the object.

    objects

    The field of objects.

  • 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 KeyPath of the object.

    objects

    The field of objects.

  • 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.

  • 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]) throws -> Self where V: Encodable, V: Hashable

    Parameters

    key

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

    objects

    The field of objects.

  • 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]) throws -> Self where V: Encodable, V: Hashable

    Parameters

    key

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

    objects

    The field of objects.

  • 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.

  • 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 KeyPath of the object.

    objects

    The field of objects.

  • 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 KeyPath of the object.

    objects

    The field of objects.

  • 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.

  • 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 KeyPath of the object.

  • Declaration

    Swift

    public func encode(to encoder: Encoder) throws

Savable - 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.

  • 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>).