Hi @ilker_cam,
Welcome to MongoDB community.
You are correct that delete trigger cannot access the full document object.
I want to offer you a workaround/trick that have worked for me in the past.
Port your delete trigger into an update trigger with fullDocument enabled and filter only updates where updated field is a ttl expired field . (Eg. deleted
flag)
Example :
{
"updateDescription.updatedFields.deleted": {
"$exists": true
}
}
Now in your collection define a 0 sec life time ttl index on this new Field :
createIndex({deleted : 1},{expireAfterSeconds : 0});
In your application logic when you need to delete a picture update this field to current time.
This will make the documents delete asap while triggering an update event.
As a result you will get an update event that a delete is on the way with fullDocument and can cleanup the file.
In your application queries make sure to query only objects without the “deleted” flag.
Please let me know if that works.
Thanks
Pavel