Help with a Trigger Match Expression

I have the following “match” expression in my trigger:

{
    "fullDocument":
    {
        "event":"A specific Desired Event"
    }
}

Problem is, with this expression, the trigger never fires. If I remove the expression, it fires for every update, and insert. I’m assuming the format of this expression is incorrect, but I’m having a heck of a time finding what it should be. Can someone give me an assist?

What I am ultimately hoping to accomplish is to only trigger when the “event” field in the “Full Document” matches a “specific event” text string.

Hi @William_Stock - Welcome to the community :slight_smile:

Could you try and test the following within the match expression code box to see if it works for your use case? :

{
   "fullDocument.event" : "A specific Desired Event"
}

There is a similar example of this in step 10 of the Create a Trigger page.

On my test environment, I had got the test trigger to run with a match expression noted below (for when the "a" field is updated to an int value of 2) :

{
   "fullDocument.a" : 2
}

Note: Once I had saved the above format match expression, reloading the same trigger then resulted with the following match expression:

{"fullDocument.a":{"$numberInt":"2"}}

Hope this helps but if not, could you provide:

  1. The MongoDB version in use
  2. The document before and after the change
  3. The update operation being run

Regards,
Jason

2 Likes

Ok, I googled and googled and never came across that article. It is most helpful. Thank, I will try your suggestion…appreciate the feedback.

1 Like

No problem - Let us know if that helps or works :slight_smile: