With this query:
const result = await Topic.find( { 'categorieName': { $regex: /^news/i } } )
I can return the categories with news name, the problem is that it is not always news, so I wanted to put a variable in place
How do I do this? I have a variable named category that is already getting the 'news' value, if I put it in the console.log, then I tried this:
const result = await Topic.find(JSON.parse('{ 'categorieName' : { $regex: /^${categoria}/i } }'));
But it did not work, what am I doing wrong?