Search code examples
javascriptparse-platformparse-serverparse-cloud-code

Parse dot com destroy all userdata from parse database


I want to set up my custom code in cloud code of parse.

Parse.Cloud.job("deleteUser", function(request, status) {    
    const query = new Parse.Query("SegmentData");
    query.equalTo("userID", request.userID);
    query.find()
    .then(Parse.Object.destroyAll)
    .catch(function(error) {
        console.error("Error finding related comments " + error.code + ": " + error.message);
    });
    const query2 = new Parse.Query("ShowData");
    query.equalTo("userID", request.userID);
    query.find()
    .then(Parse.Object.destroyAll)
    .catch(function(error) {
        console.error("Error finding related comments " + error.code + ": " + error.message);
    });
});

This is the code I have written so far. I want to destroy all the users that have username. They can be even more than 1000. Will this work if the users have more than 1000 records or do I have to amend my code?


Solution

  • With the parse-server the limit of each query is 100 you need to set to

    query.limit(1000); 
    

    If you want to have 1000 users maximum

    You can see here how parse-server test and set the limit of each query: