I have a custom API which I have made to search for job roles by title. At the moment, I can only get it if I put the entire string in eg, 'Data Analyst', but I also have roles like 'Data Scientist' and 'Data engineer'.
This is similar to WildWatch in Excel.
E.g my current API by title looks like this:
router.get("/title", async (req,res) => {
const qNew = req.query.new;
const qTitle = req.query.title;
try{
let roles;
if(qNew){
roles = await Role.find().sort({createdAt: -1}).limit(1)
} else if (qTitle){
roles = await Role.find({title: {
$in: [qTitle],
},
});
}else {
roles = await Role.find();
}
res.status(200).json(roles)
}catch(err){
res.status(500).json(err);
}
} )
But I would love for it to work like this API, from tvmaze:
http://api.tvmaze.com/search/shows?q=You
E.g if i do a GET request for the above, I receive tons of titles, all that contain 'you' in their title.
What's the way to incorporate this function into my express api?
It'll help me extremely as I map out my search functionality.
Thankyou to whoever can provide help!