I know I've used Parse.Object.destroyAll() before with much success. It does what it's supposed to and destroys all the objects you pass in.
However, I'm currently running the following code:
Parse.Cloud.job("deleteStuff", function( request, status )
{
Parse.Cloud.useMasterKey();
var stuffQuery = new Parse.Query("Stuff");
var success = new Parse.Promise();
var failure = new Parse.Promise();
stuffQuery.doesNotExist("User");
stuffQuery.limit(1000);
stuffQuery.find
(
function( stuffs )
{
console.log("There are " + stuffs.length + " stuffs found.");
return Parse.Object.destroyAll( stuffs ).then
(
function()
{
success.resolve("destroyed all the stuffs");
},
function( error )
{
failure.reject("There was an error destroying the stuffs: " + error.message);
return failure;
}
);
},
function( error )
{
failure.reject("There was an error querying for the stuffs: " + error.message);
return failure;
}
).then
(
function( success )
{
status.success( "deleted all the stuffs with no users" );
},
function( error )
{
status.error( error );
}
);
});
Pretty straight forward. Query for any "Stuff" object that doesn't have a User attached to it. Delete all the results. There is a console log that is printing out how many objects are in the array returned by the query. It is telling me there are over 400 objects to delete.
But, when I refresh the dashboard, the total count only goes down by 20. I've run it multiple times, and each time it's only removing 20.
This is being run on our test server, and I need it to run on my live server where there are over 3000 of these objects with no User attached... I'm not deleting 3000 objects 20 at a time...
Any idea why or when Parse.Object.destroyAll isn't working here?