2020-04-26

MongoDB - IF statement using field regex match condition

"field_name_here":
    {"$cond": [
        {$regexMatch: {
            input: "$source_field_name_here",
            regex: /string_to_match_here/i
        }}
        , NumberInt(1) //value if matched
        , NumberInt(0) //value if not matched
    ]},

No comments:

Post a Comment