1
votes

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

1 Answers

1
votes

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.