I have a project mongoose schema that contains the title and description of each project, and a ticket mongoose schema that also contains the title of the project the ticket is relevant to as well as the name of the user that the ticket is assigned to. Each individual project will be displayed on a post.ejs page, and I want to display the names of users who have been assigned tickets relating to that particular project.
Here is the get request so for the post.ejs page:
app.get("/posts/:postId", isLoggedIn, function(req, res) {
const requestedPostId = req.params.postId;
ProjectDetails.findOne({_id: requestedPostId}, function(err, post) {
const tickets = TicketDetails.find({project: post.title});
console.log(tickets);
res.render("post", {title: post.title, content: post.content});
});
});
I’m first querying the project database to find the project, then I’m querying the ticket database for all tickets related to the project, but when i console.log tickets I get an output like this: