How to relation request object in cloud function

Hello guys, I’m trying to relate the request.object that I receive in a cloud function through afterSave but the relationship remains blank… this is my code…

Moralis.Cloud.afterSave('eventName', async (request, response) => {
  	const confirmed = request.object.get('confirmed')
    
    if (!confirmed) {
    	return true
    }
    
    // create and set row
    const userD = Moralis.Object.extend('Deposits')
    const userDeposit = new userD()

    // set
    const prop = request.object.get('prop')
    userDeposit.set('prop', prop)

  	// relation
  	const relation = userDeposit.relation('event') // event is name row on Deposit Class
    relation.add(request.object)
  
  	// save
	await userDeposit.save()
  
  	return true
});

If I manage to get a relationship but it says that there are 0 objects, try also with the ID as the doc says but it gave me the discrepancy error.

How could I do it? I need to make only one relationship.

Here you may need to create a relation object.

Maybe it is easier to use pointers.

My understanding is that you are trying to add a relation between class eventName and userDeposite, where evenName is the parent class and userDeposite is the child class.

I guess u can also achieve this with

const event = request.object;
userDeposit.set("parent", event);

Your code also looks correct, but not sure what is wrong.