Rollback after parsing

I am using parse.com here is the scenario: I have 2 classes A and B

step 1: create an object of class A Step 2: create a pointer from class B to the newly created object (in class A).

I want to return the role - delete the class A object if step 1 was successful and step 2 failed.

In the parsing documentation, I have not seen any rollback strategy built into the system. what would be the best solution? thank

+3


source to share


1 answer


I don't think Parse offers an easy way to guarantee chaining operations, but this is how I would do it in Swift:



let objectA = ClassA()
objectA.saveInBackgroundWithBlock { success, error in
    if success {
        objectB.objectA = A
        objectB.saveInBackgroundWithBlock {
            if !success {
                objectA.deleteEventually()
                objectB.removeObjectForKey("objectA")
            }
        }
    }
}

      

0


source







All Articles