({ useMasterKey: true }) in cloud functions

I’m using this cloud function to set new parameters in DB

Moralis.Cloud.afterSave("minted", async (request) => {
    const logger = Moralis.Cloud.getLogger();
    logger.info("running afterSave -> minted")

    const query = new Moralis.Query("minted", {useMasterKey: true});
    query.equalTo("tokenId", request.object.get('tokenId'), { useMasterKey: true });
    const item = await query.first({useMasterKey: true});

    const itemObj = JSON.parse(JSON.stringify(item))

    if (item && typeof itemObj.attempt === "undefined") {
        const httpResponse = await Moralis.Cloud.httpRequest({
            "url": `${itemObj.uri}`,
            "headers": {
                'method': 'GET',
                'accept': 'application/json'
            }
        })

        const result = httpResponse.data;

        request.object.set('item', item, {useMasterKey: true});
        item.set('guessed', false);
        item.set('attempt', 0); //Number.isInteger(item.attempt) ? item.attempt + 1 : 0

        if (result) {
            item.set('img', result.image);
            item.set('wordbroken', result.words);
            item.set('prize', result.prize);
            item.set('attempt_price', result.attemptCost);
        }

        await item.save(null, {useMasterKey: true});
    }
});

It works fine, but I cannot set the CLP of the Role class to anything less than Public write, which makes no sense.
It’s because the item.save() function has no access and doesn’t work with { useMasterKey: true } to override the CLP.
Am I using the wrong approach?

I don’t know how you could modify the CLP from code, that setting is per class and not per row

ok, How i need to set MasterKey for save data in DB in my functions. I tryed different ways to use MasterKey but cant save it

it looks like you are using the right syntax, any error?

Permission denied for action update on class minted.

did you try with some simpler update to see if it works

you don’t have to use that useMasterKey parameter for all those lines, like for .set