We have a desire to have a Trigger fire regardless of collection, and it’s not clear if this is supported or not.
At present we seem to be getting this error when we specific Cluster and Database but not a Collection:
error issuing collMod command for becollective.: (InvalidNamespace) Invalid namespace specified 'becollective.'
I have a feeling Triggers might only work when you specify a Collection? It’s not specifically mentioned whether or not Triggers work this way.
(Edit) Given that ChangeStreams can listen to all collections as specified in the link below, I’m expecting that it should be possible, but it’s not clear whether Triggers use this .watch() format.
The error you mentioned seems to indicate that you are trying to create a trigger without specifying a collection, which is not supported by MongoDB.
Regarding ChangeStreams, they do allow you to listen to all changes in a MongoDB deployment by using the
$match stage to specify an empty query. However, this is different from triggers. ChangeStreams are a way to subscribe to the change events happening in a MongoDB cluster, but they are not the same as triggers.
Triggers are part of the MongoDB Realm platform and are used to respond to specific changes in a collection by executing serverless functions or other actions. They are designed to be collection-specific and do not work at the database or cluster level.
If there have been updates or changes to MongoDB after my knowledge cutoff date, I recommend checking the MongoDB documentation or release notes for the latest information on triggers and their capabilities. MongoDB’s documentation is comprehensive and frequently updated, so you can find the most up-to-date information there.
Thanks, that’s exactly my question though; the documentation doesn’t specifically state that you CAN’T do database level triggers - and after all it lets me save the function whereas anything else throws errors, and the lack of an error when not selecting a collection led me to believe that this is therefore supported.
I believe Triggers are state functions using ChangeStreams but I guess only on a per-collection basis.
Hey Mark, you are correct Atlas App Services currently only supports Collection level triggers. However, I’m excited to share the team is in the process of adding support for Deployment and Database level triggers and it should be available later this quarter.
Thanks for the reply Frank, hope to see this feature live soon! I guess for now we’ll rollback our existing per-collection Function method (we migrated aws-sdk to v3, but SQS SendMessage fails with node10, as per other thread).