Swift Deleting multiple objects at once Parse server

I ask the server after

let query = PFQuery(className: "posts")
            query.whereKey("uuid", equalTo: Ncell.uuidLbl.text!)
            query.findObjectsInBackground { (objects:[PFObject]?, error:Error?) in
                if error == nil {
                    for object in objects! {
                        object.deleteInBackground(block: { (success:Bool, error:Error?) in
                            if success{

                            }
                        })
                    }
                }
            }

      

Instead of using a loop and deleting each object separately, I want to know if it will be possible to delete all found objects at once to keep the queries.

+3
ios swift parse.com parse-server


source to share


1 answer


I want to know if it will be possible to delete all found objects at once

Yes in Parse iOS SDK to delete multiple objects at once in the Parse server background , you can use deleteAllInBackground

You can use it in two different ways:

PFObject.deleteAll(inBackground: [PFObject]?)
PFObject.deleteAll(inBackground: [PFObject]?, block: PFBooleanResultBlock?)

      



For example:

let query = PFQuery(className: "posts")
query.whereKey("uuid", equalTo: Ncell.uuidLbl.text!)
query.findObjectsInBackground { (objects:[PFObject]?, error:Error?) in
    if error == nil {
        PFObject.deleteAll(inBackground: objects, block: { (success:Bool, error:Error?) in
                if success {

                }
            })
        }
    }

      

Hope my answer was helpful :)

+5


source to share







All Articles
Loading...
X
Show
Funny
Dev
Pics