How do I save the request.object to another table?

How do I save the request.object to another table?

Moralis.Cloud.beforeSave("BscNFTOwners", async (request) => {


  const userQuery = new Moralis.Query("User");

  userQuery.equalTo("ethAddress", request.object.get('owner_of'));

  const userQueryResults = await userQuery.first({useMasterKey: true});


  const logger = Moralis.Cloud.getLogger();;

  if(userQueryResults) {

    const Notification = Moralis.Object.extend("Notification");

    let notifObject = new Notification();

    const BscNFTOwners = Moralis.Object.extend("BscNFTOwners");

    let bscNFTOwnersObject = new BscNFTOwners();

    bscNFTOwnersObject = request.object;

    notifObject.set("user", userQueryResults);

    notifObject.set("BscNFTOwners", bscNFTOwnersObject);,{useMasterKey:true});



This code gave me an error of
“Cannot create a pointer to an unsaved ParseObject”

You are in beforeSave here, in case that you want to use current object, it is not yet saved, you could use after save maybe.

1 Like

Ohhh that makes sense, thanks a lot!
However, can I use request.object to save it or just get the latest data from the saved value?

I think that you can modify what you have in request.object, you don’t need to save it in beforeSave as you don’t want to enter in an infinite loop.