I am trying to access body inside blog schema. How can I do it.
Schema:
var ArticleSchema = new mongoose.Schema({
blog: [{
topic: { type: String, unique: false, lowercase: true },
body: { type: String, unique: false, lowercase: true },
tags: [ 'first', 'mongodb', 'express'],
created: Date,
modified: { type : Date, default : Date.now },
state: { type: String, unique: false, lowercase: true }
}]
});
**
router
**
router.get('/blog/article/:postid', function (req, res, next) {
Article.findById({ _id: req.params.postid }, function (err, article) {
if (err) return next(err);
res.render('main/publishedArticle', {
article: article,
message: req.flash('showing article ' + article.title)
});
});
});
**
publishedArticle.ejs
**
<h3><%= article.blog.body %></h3>
I am am getting undefined