It doesn't update the table for me. need help thanks

Good evening, I am new to the community. I would like to ask for help and clarify some doubts about the clouds functions please. I have afterSave that activates a beforeSave for me. I leave the 2 clouds at the end. I explain the problem:

  • I need to update a table when executing afterSave. but the beforeSave is activated by the applied logic. I tried to skip beforeSave with context but the empty object arrives. Investigating the solution was to create a temporary class to skip the Triggers. since it is an internal validation. That is, the AuctionwithdrawnLogs table is created, and it should save the internal object. it fires the beforeSave of ItemsMinted, but it doesn’t update the table for me. please help. I have tried everything. grateful for the time and help.
Parse.Cloud.afterSave('AuctionwithdrawnLogs', async (request: any) => {

  const { tokenId, nftContractAddress } = request.object;

  const tokenIdReqtoInt = parseInt(tokenId);

  console.log('tokenIdAuctionwithdrawnLogs', tokenIdReqtoInt);

  console.log('nftContractAddressAuctionwithdrawnLogs', nftContractAddress);

  try {

    const TempData = Parse.Object.extend('TempData');

    const tempData = new TempData();

    tempData.set('afterSave', true);

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

    const Data = Parse.Object.extend('ItemsMinted');

    const query = new Parse.Query(Data);

    query.equalTo('tokenId', tokenIdReqtoInt);

    query.equalTo('collectionAddress', nftContractAddress);

    // let object: any = await query.first({ useMasterKey: true })

    query.first({ useMasterKey: true })

    .then((object: any) => {

      if (object) {

        console.log('EntroAuctionwithdrawnLogs');

 

        // Actualizar campos específicos

        object.set('buyNowPrice', 0);

        object.set('minimumBid', 0);

        object.set('forSale', false);

 

        // Usar el método update para aplicar los cambios

        return object.save(null, { useMasterKey: true });

      }

        console.log('No se encontró el objeto de ItemsMinted');

        return Promise.resolve();

     

    })

    .then(() => {

      console.log('Objeto actualizado con éxito');

    })

    .catch((error) => {

      console.error('Error al actualizar el objeto:', error);

    });

   

    // if (object) {

    //   console.log('EntroAuctionwithdrawnLogs');

    //   // log.info();

    //   object.set('buyNowPrice', 0);

    //   object.set('minimumBid', 0);

    //   object.set('forSale', false);

    //   object.save();

    //   console.log('endAfter');

     

    // }

  } catch (error) {

    console.log('errorAuctionwithdrawnLogs', error);

  }

});
Parse.Cloud.beforeSave('ItemsMinted', async (request: any) => {

  const { user, object, context  } = request;

    const TempData = new Parse.Query('TempData');

    TempData.equalTo('afterSave', true);

    const tempData = await TempData.first({ useMasterKey: true });

   

    const validate = tempData?.get('afterSave');

    if( validate){

      await tempData?.destroy({ useMasterKey: true });

      return

    }

    console.log('entreAquiAdminUser2', user);

    console.log('request', request);

    console.log('object', object);

    console.log('context ', context );

   

    if (user) {

      const ethAddress2 = user.get('ethAddress');

      console.log('entreAquiAdmin');

      const roleName = 'admin';

      const isAdmin = await Parse.Cloud.run('checkUserRole', { roleName, ethAddress2 });

      console.log('isAdmin', isAdmin);

      if (isAdmin.hasRole) {

        console.log('entreAquiAdminReturn');

        return;

      }

    }

       

    const nftContractAddress = context && context.nftContractAddress ? context.nftContractAddress : object.get('collectionAddress');

    const tokenId = context && context.tokenId ? context.tokenId : object.get('tokenId');

   

    console.log('nftContractAddress', nftContractAddress);

    console.log('tokenId', tokenId);

    console.log('tokenIdTypeof',typeof tokenId);

    if (!nftContractAddress || tokenId === null || tokenId === undefined) {

      throw new Error('collectionAddress and tokenId must be provided.');

    }

    const query = new Parse.Query('SalecreatedLogs');

    query.equalTo('nftContractAddress', nftContractAddress);

    query.equalTo('tokenId', tokenId.toString());

    const objectExists = await query.first({ useMasterKey: true });

    if (!objectExists) {

      throw new Error(

        'An object with the given nftContractAddress and tokenId already exists in SalecreatedLogs. Cannot create duplicate entry in ItemsMinted.',

      );

    }

});

Solved the problem, please close