Hey there, I'm facing an issue with using the search query of mongoose. I want to make a get request using a query, but it seems that it's not possible. I'm puzzled by this error as I'm currently working with version 5.10.0 of mongoose.
I prefer not to use a post request or req.body. Can someone provide some assistance?
Here's my code snippet:
export const searching = (req: Request, res: Response) => {
Company.find({ $text: { $search: req.query } }).exec((err, docs) => {
if (docs) {
res.status(200).json(docs)
} else {
console.log(err)
}
})
}
And here's the error message I am getting:
(property) $search: string
No overload matches this call.
The last overload gave the following error.
Type 'ParsedQs' is not assignable to type 'string'.ts(2769)