83
rated 0 times
[
86]
[
3]
/ answers: 1 / hits: 25715
/ 1 Year ago, mon, february 27, 2023, 12:00:00
I've been using callbacks for .save() and .findOne() for a few days now and just today I encounter these errors:
throw new MongooseError('Model.prototype.save() no longer accepts a callback')
MongooseError: Model.prototype.save() no longer accepts a callback
and
MongooseError: Model.findOne() no longer accepts a callback
It's really awkward given that callbacks are still accepted in the docs at least for .findOne().
app.post("/register", (req, res) => {
const newUser = new User({
email: req.body.username,
password: req.body.password
});
newUser.save((err) => {
if (err) console.log(err)
else res.render("secrets");
});
});
This is what used to work for me, using express and mongoose. Please let me know how to fix it.
More From » mongodb