i am trying to make a search api using mongodb .This is what i did;
export const searchRomance=async (req,res) => {
const nameis=req.params.key
const searchR = await romances.find({
name:nameis
})
if(!searchR ) res.status(400).send({error : "No task was found"})
res.status(200).send(searchR)
}
and this is how i made the route ==>router.get('/search/:key',searchRomance);
when i do this instead of getting only the search result am getting everything!. please answer.