1

I have this code that I have written as I am trying to delete a class that has more than a thousand object, but are sorted under different categories. But when I run it still only deletes 1000 objects. Here is what I have:

Parse.Cloud.job("delete", function(request, response) {


  var array = ['A', 'B', 'C',];

  for (var i=0; i < schoolArray.length; i++) {
        var TestItem = Parse.Object.extend("TestItem");
        var query = new Parse.Query(TestItem); 
        query.limit(1000); 
        query.equalTo('school', array[i]);  
        query.find({
            success:function(results) {
                console.log('school: ' + array[i]);
                console.log('length'+results.length);
                for (var i = 0; i < results.length; i++) {
                    var myObject = results[i];
                    myObject.destroy({
                        success: function(myObject) {
                        // The object was deleted from the Parse Cloud.
                        },
                        error: function(myObject, error) {
                            // The delete failed.
                            // error is a Parse.Error with an error code and description.
                        }

                    });
                }   
            },
            error: function(error) {
                console.log("Failed!");         
            }
        });
    } 
});

And it only deletes the 1000 objects, but I want it to delete 1000 for the category A, B and C.

1 Answer 1

1

From the code you provide it looks like schoolArray is not defined.

You should fix that or iterate the variable named array instead of schoolArray in the first for.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.