Hi campers,
I’m back to Node after a hiatus. Going through the quality assurance lessons again, I found something on the lesson “Registration of New Users” that I don’t understand:
https://www.freecodecamp.org/learn/quality-assurance/advanced-node-and-express/registration-of-new-users
What does it mean that the “inserted document is held within the ops property of the doc”? What is the ops property? Is there a link to a MongoDB documentation that properly explains how the document in stored? (NOT using Mongoose)
doc.ops[0]
app.route('/register')
.post((req, res, next) => {
myDataBase.findOne({ username: req.body.username }, function(err, user) {
if (err) {
next(err);
} else if (user) {
res.redirect('/');
} else {
myDataBase.insertOne({
username: req.body.username,
password: req.body.password
},
(err, doc) => {
if (err) {
res.redirect('/');
} else {
// The inserted document is held within
// the ops property of the doc
next(null, doc.ops[0]);
}
}
)
}
})
},
passport.authenticate('local', { failureRedirect: '/' }),
(req, res, next) => {
res.redirect('/profile');
}
);