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 :
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
Hi @Moumouls Thanks
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’);
worker.save();
}
// 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
}
})