Hey ya’ll,
I have an aggregation pipeline that have been tested in my VSCode playground, everything works good there, however when I try and use it in my app services functions regex can’t find a match even though there is data with the right format and totally works in vscode playground.
{
case: {
$regexMatch: {
input: '$Quotemeal',
// eslint-disable-next-line prefer-regex-literals
regex: new BSON.BSONRegExp("^([1-9]|0[1-9]|1[0-2])[-/]([1-9]|0[1-9]|[12][0-9]|3[01])[-/](\d{4}|\d{2})$"),
}
},
then: {
$let: {
vars: {
dateParts: {
$regexFind: {
input: '$Quotemeal',
// eslint-disable-next-line prefer-regex-literals
regex: new BSON.BSONRegExp("^([1-9]|0[1-9]|1[0-2])[-/]([1-9]|0[1-9]|[12][0-9]|3[01])[-/](\d{4}|\d{2})$"),
}
},
},
in: {
dateParts: '$$dateParts'
// $dateFromParts: {
// year: { $toInt: { $arrayElemAt: ['$$dateParts.captures', 2]} },
// month: { $toInt: { $arrayElemAt: ['$$dateParts.captures', 0]} },
// day: { $toInt: { $arrayElemAt: ['$$dateParts.captures', 1]} },
// },
},
},
},
},
I’ve added the eslint-disable and the new BSON.BSONRegExp as per a similar post I found here, because before that I only got this error back: Failed to optimize pipeline :: caused by :: $regexMatch needs ‘regex’ to be of type string or regex
Has anyone has had a similar issue when using App Services Functions?
Thank you in advance