Created
May 12, 2021 16:16
-
-
Save nkenna/081ef50876f34f4564ea2926bfa4febd to your computer and use it in GitHub Desktop.
check if this will work for you. I am using it on mediabar and that donation platform.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.searchCreators = (req, res) => { | |
var result = {}; | |
var query = req.body.query; | |
User.find({$text: {$search: query}}) | |
.select("-password") | |
.populate('supporters') | |
.sort('-createdAt') | |
.then(users => { | |
result.status = "success"; | |
result.message = "users found"; | |
result.users = users; | |
return res.status(200).send(result); | |
}) | |
.catch(err => { | |
console.log(err); | |
result.status = "failed"; | |
result.message = "error occurred finding users"; | |
return res.status(500).send(result); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment