Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse Unpin Does Not Remove Object From Local Datastore

Tags:

This should work.

Here is one of many attempts to get this figured out

            myTrainingSessions[indexPath.row].unpinInBackgroundWithBlock{ (succ, e) -> Void in
            if succ == true {

                // just remove from table view etc
                self.myTrainingSessions[indexPath.row].deleteEventually()
                self.myTrainingSessions.removeAtIndex(indexPath.row)
                self.tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)

                // Shows that my object is still in datastore!
                // object should be UNPINNED - but appers in this result....
                var query = PFQuery(className:TrainingSession.parseClassName())
                query.whereKey(self.userType(), equalTo: PFUser.currentUser())
                query.orderByDescending("createdAt")
                query.fromLocalDatastore().ignoreACLs()
                query.findObjectsInBackgroundWithBlock { (objects, error) -> Void in
                    if error != nil { return }
                    if let result = objects as? [TrainingSession] {
                        println("local results")
                        println(result)
                    }
                }


            }
        }

I do a query after unpinning and the object is still there.

like image 938
DogCoffee Avatar asked Apr 06 '15 05:04

DogCoffee


2 Answers

I've contacted the support team about the problem where you can't unpin an object that has a referenced object, so I'm sharing the thread for those interested:

https://developers.facebook.com/bugs/138298746504630/

The support person said it was By Design, but upon my request to improve this specification, he told me he would tell the team about it.

like image 130
Koichi Yamamoto Avatar answered Jan 03 '23 04:01

Koichi Yamamoto


One of the reasons this is not working for you is because there might still be objects in your local datastore that have relation with the object you want to unpin. To do this properly, unpin all those objects first and then unpin the target object.

like image 41
Waqar Ahmed Avatar answered Jan 03 '23 04:01

Waqar Ahmed