Include metadata in Atlas trigger event data

Is there a way to pass metadata through update queries for Atlass triggers in order to tie events back to the update queries?

Sounds abstract, I know. But let me try to explain as simply as possible.

Let’s say, I have an Atlass trigger on a collection.

Now, let’s say multiple update queries happen nearly at the same time: user A changes documents 1, 2, and 3, at the same time user B changes 1, 2, and 3 and user A changes documents 4, 5 and 6 in another browser tab.

The trigger events I get would look something like this:

  • document 1 updated
  • document 1 updated
  • document 2 updated
  • document 2 updated
  • document 3 updated
  • document 3 updated
  • document 4 updated
  • document 5 updated
  • document 6 updated
    (in any random order).

Now, my requirement is to send feedback back to the users like:

  • “Hey user A, your changes to 1, 2, and 3 in this browser tab succeeded”
  • “Hey user B, your changes to 1, 2, and 3 in this browser tab succeeded”
  • “Hey user A, your changes to 4, 5, and 6 in this browser tab succeeded”

With the trigger events right now, I don’t have a chance to do that. Sure, I know that user A tried to update document 1, but if a trigger event like “document 1 updated” comes back, how would I know if this was triggered by user A or user B?

So, what I would love to have is something like:

updateMany({ ... update: 1,2,3 }, { metadataForTrigger: { userId: "A", myProp: 'abc' } })
updateMany({ ... update: 1,2,3 }, { metadataForTrigger: { userId: "B", myProp: 'def' } })
updateMany({ ... update: 4,5,6 }, { metadataForTrigger: { userId: "A", myProp: 'ghi' } })

And then the events would look like:

  • document 1 updated, { metadataForTrigger: { userId: “A”, myProp: ‘abc’ } }
  • document 1 updated, { metadataForTrigger: { userId: “B”, myProp: ‘def’ } }
  • document 2 updated, { metadataForTrigger: { userId: “A”, myProp: ‘abc’ } }
  • document 2 updated, { metadataForTrigger: { userId: “B”, myProp: ‘def’ } }
  • document 3 updated, { metadataForTrigger: { userId: “A”, myProp: ‘abc’ } }
  • document 3 updated, { metadataForTrigger: { userId: “B”, myProp: ‘def’ } }
  • document 4 updated, { metadataForTrigger: { userId: “A”, myProp: ‘ghi’ } }
  • document 5 updated, { metadataForTrigger: { userId: “A”, myProp: ‘ghi’ } }
  • document 6 updated, { metadataForTrigger: { userId: “A”, myProp: ‘ghi’ } }

I could not find any such functionality. So, how do I solve that? Trying to include such metadata into the document itself looks tricky. Are there any best practice examples?