I just noticed some weird thing about triggers. I followed the below steps,
- I created a new collection test1.
- I created a database trigger for test1 with insert, update and replace Operation types.
- I disabled the above trigger, because I wanted to transform and merge the data to test1 from temp collection using aggregates. During this process, I did not want trigger to fire, so I disabled the triggers on test1 collection.
- After merging the data to test1, I enabled the triggers on test1 collection again but surprisingly trigger has fired for all the documents which were inserted to test1 when trigger was disabled (i.e. during aggregate migration). I am not sure how did it happen. And, I want to stop this from happening because merging the data from temp to test1 will have millions of records and I don’t want trigger to get fired for all those documents during this process.
Can anyone please let me know what is wrong with my approach? Basically, I don’t want trigger to get fired for the documents which are inserted/updated/replaced when trigger was disabled.