I am using a serverless + atlas API arquitecture.
This has worked for the last two years and all of a sudden my queries return empy.
This is in my handler:
module.exports.getByString = (event, context, callback) => {
context.callbackWaitsForEmptyEventLoop = false;
connectToDatabase()
.then(() => {
var nameRegex = new RegExp(event.pathParameters.query);
console.log(event.pathParameters.query);
Cosmetic.find({product_name: {$regex: nameRegex, $options: 'iu'}}).collation({locale: 'fr', strength: 2})
.then(notes => callback(null, {
statusCode: 200,
body: JSON.stringify(notes)
}))
.catch(err => callback(null, {
statusCode: err.statusCode || 500,
headers: { 'Content-Type': 'text/plain' },
body: 'Could not fetch the notes.'
}))
});
};
If I search directly on Atlas it works:
When I test it on AWS Lambda it also returns the same:
{
“statusCode”: 200,
“body”: “”
}
for the JSON input:
{
“pathParameters”: {
“query”: “Mazz”
}
}
Does anyone know what is happening?