I have created a schema in mongoosejs that looks like this:
var uploadSchema = mongoose.Schema({
title : String,
happy : String,
});
I am trying to show the data from my database on the client side (using ejs for templating):
app.get('/yay', function (req, res, next){
Upload.find({}, function (err, course){
res.render('./pages/yay.ejs', {course: course});
});
});
When displaying it on the client side:
<div class="well">
<p><%= course %></p>
</div>
Unfortunately, this code displays the entire database entry including the id and whatWillLearn. I only want to display the title. How can I achieve this? I attempted the following:
app.get('/yay', function (req, res, next){
Upload.find({}, function (err, course){
res.render('./pages/yay.ejs', {course: course.title});
});
});
However, this just shows 'undefined' on the client side. Any suggestions on how to fix this issue?