Heres the cloud function:
Moralis.Cloud.afterSave("Cue", async (request) => {
const query = new Moralis.Query("Cue");
const confirmed = request.object.id;
query.equalTo("objectId", confirmed);
globalLog.info("Confirmed = " + JSON.stringify(confirmed));
result = await query.first(({useMasterKey: true}));
globalLog.info("Query Result aftersave = " + JSON.stringify(result));
const shouldDelete = result.get('isDeleted');
if (shouldDelete === true) {
globalLog.info("Delete is TRUEEEEEEEE == " + JSON.stringify(result));
await result.destroy(null, {useMasterKey:true}).then(() => { globalLog.info("success");},(error) => {globalLog.info(error);});
globalLog.info("Object should be deleted");
} else {
// handle unconfirmed case
}
});```
Getting object not found even though i have logged the object in the lines above the destroy call. Any help is appreciated.