It is possible to trigger Relation?

i want to figure out from cloud code when an object has been removed from a relation so that i can edit his contain instead of sending 2 request to the server. (one for removing and one for updating)

so what i need is to know if it is possible to trigger the Relation operation:

here Payload of answer on my client after removing :


Hi @Surmesure

In in the cloud code you can use const ops = request.object.op('workers') to detect ops on relation and implement custom code/events related to Relation operations :slight_smile:

Hi @Moumouls Thanks :slightly_smiling_face:
it doesn’t seem to work or I’m using it wrong. is it supposed to return an Event?

Parse.Cloud.afterSave(‘Order’, async (request) => {
const order = request.object;
const relation = order.relation(‘workers’);
var query = relation.query();
const results = await query.find();
for (let i = 0; i < results.length; i++) {
const worker = results[i];
worker.set(‘status’, ‘Beschäftigt’);;

// need to set status of worker who will be remove from the relation here
if(order.op(‘workers’) == ‘RemoveRelation’){
// this op is it a String Event ?
// my code will be here

referring to @davimacedo 's post on this issue :

I could solve the problem by transforming my Object into Json an get something like:

const order = request.object;
const orderJson = order.toJSON();
const operation = orderJson.workers.__op;
const selectedWorkers = orderJson.workers.objects;