I only want to pull data unique to a user where my req.user === foundListing.uid. How can I adjust this function to only show those objects?
function show(req, res) {
db.User.findById(req.user, function (err, user) {
console.log(req.user)
if (err) {console.log(err);}
db.Listing.findById(req.params.listingId, function(err, foundListing) {
console.log(foundListing.uid );
if(err) { console.log('listingsController.show error', err); }
res.json(foundListing);
});
})
}
userfirst, and after thatlistings? Iflistingsis related touseryou can create only one request, otherwise this select is unneeded.