What is your hint or solution suggestion?
Your solution should include two functions (they are both given to you):
- A serialization function
- A deserialization function (the db.collection should be commented out because we have not yet set up our DB)
Also add const ObjectID = require('mongodb').ObjectID;
to your server.js file (To make a query search for a Mongo _id)
The 2 functions:
passport.serializeUser((user, done) => {
done(null, user._id);
});
passport.deserializeUser((id, done) => {
db.collection('users').findOne( // comment out starting here
{_id: new ObjectID(id)},
(err, doc) => {
done(null, doc);
}
); // Comment out until here
});
Don’t forget to add mongoose and mongodb as dependencies in the package.json file
Challenge: Serialization of a User Object
Link to the challenge: