Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

mongoose + populate

app.get('/movies', passport.authenticate('jwt', { session: false }), (req, res) => {
	Movies.find()
		.populate('Genre')
		.populate('Actor')
		.populate('Director')
		.then((movies) => {
			res.status(201).json(movies);
		})
		.catch((err) => {
			console.error(err);
			res.status(500).send(`Error: ${err}`);
		});
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #mongoose #populate
ADD COMMENT
Topic
Name
4+3 =