Trigger function when data is updated?

Hey Daniel, I tried your trick, but I still struggle get it right with the following code:

Parse.Cloud.afterSave("PrsProfile", async ({object, original = new Parse.Object(), log}) => {
    const newPh = object.get('ph');
    const origo = original.get('ph');
    log.info(`photo urls has changed: ${(origo !== newPh)}, new: ${newPh}, old: ${origo}`);
    if (origo !== newPh) {
        try {
            await checkPhotosForDelete(object.id, newPh, log);
        } catch (e) {
            log.error(`error checkPhotosForDelete: ${e}`);
        }
    }
});

As you can see here, it see it that they are not the same, even they are. It has no effect if I use !== or != for comparison:

photo urls has changed: true,
new: ,file:///https:/parsefiles.back4app.com/coYfuTYV3z35Z8iwv8q3NOTdGQs2ywJtt7tUUg4p/7e04ef50c3364e2acaa7b7559ae85681_v00_1.jpg
old: ,file:///https:/parsefiles.back4app.com/coYfuTYV3z35Z8iwv8q3NOTdGQs2ywJtt7tUUg4p/7e04ef50c3364e2acaa7b7559ae85681_v00_1.jpg

I think there might be something wrong in how it takes the array? Because here I have an Array of optional Strings [String?] and later in the code I am trying to check if any of the saved urls are missing in the newPh array:

checkPhotosForDelete = async function(profileId, newPhotoUrlsArray, log) {
    if (Array.isArray(newPhotoUrlsArray) == false) {
        throw `newPhotoUrlsArray is not an array ${newPhotoUrlsArray}`;
    }
    const filesQuery = new Parse.Query("FileObj");
    filesQuery.equalTo('ow', profileId);
    filesQuery.find({useMasterKey: true}).then((fileObjects) => {
        log.info(`found fileObjects: ${fileObjects.length}`);

        for (let i = 0; i < fileObjects.length; ++i) {
            const profilePhoto = fileObjects[i].get("file");
            const url = profilePhoto.url();
            log.info(`includes: ${newPhotoUrlsArray.includes(url)}, url ${url}`);
            if (newPhotoUrlsArray.includes(url) == false) {                
                return profilePhoto.destroy({ useMasterKey: true });
            }
        }
    }).catch((error) => {
        log.info(`Error checking photos to delete ${error.code}: ${error.message}`);
    });
}

and there is the line newPhotoUrlsArray.includes(url) returning false even when the url is in the array. I believe I got lost again in the javaScript weak typing or how it is called.