Hello @Dev_Ops ,
Can anyone let me know if what I am trying to do is even possible?
Sorry for the late reply. I have tried to find an answer to this and have scaled this problem internally to be able to use a
$match expression each time the
accepted field is updated regardless of the
index added. Please, allow me some time to investigate this.
$match expression for this is not straightforward as it will need to use a sort of
$regex expression. However, in the meantime, I looked for a workaround using the
$addToSet. Every time you use
$addToSet, the element will be added to the end of the array but you need to be aware that MongoDB Realm limits the execution of Trigger Functions to a rate of 1000 executions per second per Trigger. If there are additional Trigger executions beyond this threshold, MongoDB Realm adds their associated Function calls to a queue and executes each one when the capacity becomes available.
If you add in your trigger your
$match expression as follows:
This will make the trigger run every time you update your
accepted array and you will get all the elements plus the element added, so to be able to get the
ID added and sent it to AWS Eventbridge, you could benefit from the following
This will result in a field called
lastID that will contain the latest
ID added to the
accepted array in the
Please let me know if this adequately addresses your questions.