Is there a way for me use this code or a similar code to find by username instead of findById?
Router.route('/:id').get(function (req, res)
{
let id = req.params.id;
Books.findById(id, function (err, course) {
res.json(course);
});
});
Books.find({username: 'username'},function (err, course) {res.json(course);});
or
Books.find({username: /username/i},function (err, course) {res.json(course);}); // Like operator
I hope it works Look at Mongoose Docs here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With