Saving a user's favorites Saving a user's favorites mongoose mongoose

Saving a user's favorites


You can define a User schema like this:

var User = new Schema({    favorites: [{        whatHaveYou: String,    }]})

Now, with using passport.js, after you have authenticating the user with this schema, you will be able to access the favorites with: req.user.favorites.

I suggest you go throw this demo project on github for setting up a node-express-mongoose project with passportjs if you have any more questions: https://github.com/madhums/node-express-mongoose-demo, this helped me a lot.