Permission denied when trying to destroy objects from cloud code

Following code throws error: permission denied

Moralis.Cloud.define("deleteMintEvents", async request => {
  try {
    const query = new Moralis.Query("EthNFTTransfers");
    query.equalTo("from_address", "0x0000000000000000000000000000000000000000");
    const result = await query.find();
    for (let i = 0; i < result.length; i++) {
      result[i].destroy(null, { useMasterKey: true });
      logger.info("deleting object " + JSON.stringify(result[i]))
    }
  } catch (error) {
    logger.info("Error: " + JSON.stringify(error));
  }
});

did you also try with destroy({ useMasterKey: true });?

yea I tried that too but its not deleting anything. Also hard to debug the logs when the server has a bunch of cloud functions cause logs appear super laggy or not at all. The logging functionality for Moralis needs to be imrpooved heavily imho.

for logging, you can also use moralis-admin-cli to save logs real time on your local system and search them later

does that table have special rights for deleting objects? it looks like .find didn’t use master key

I didnt apply any special rights to it, i left it how it was when starting to sync data only added few more fields on the beforeSave trigger.

maybe you don’t even need master key parameter in that case if anyone can delete those objects