title: Working with related documents-population and models
body: <p>I'm pretty new to these technologies and I don't know if I'm getting it right.
  <br> 
  I'm trying to print in the table the name of the category instead of the id (ObjectId schema field) of all the documents Category related to the documents Post. But it keeps showing the id. Help please!</p>
  
  <p><strong>routes/posts.js</strong></p>
  
  <pre><code>Post
          .find({})
          .populate('Category')
          .exec((err, posts) =&gt; {
              if (err) return res.json({ error: err })
              posts.category = posts.category.name
              res.render('posts/index', {
                  postList: posts
              })
          })
  </code></pre>
  
  <p><strong>models</strong></p>
  
  <pre><code>let categorySchema = new Schema({
      name: String,
      posts: [{ type: Schema.Types.ObjectId, ref: 'Post' }]
  })
  module.exports = mongoose.model('Category', categorySchema)
  
  let postSchema = new Schema({
      title: String,
      content: String,
      date: String,
      category: {type: Schema.Types.ObjectId, ref: 'Category' }
  })
  module.exports = mongoose.model('Post', postSchema)
  </code></pre>
  
  <p><strong>views/posts/index.pug</strong></p>
  
  <pre><code>tbody
              each post in postList
                  tr
                      td #{post.title}
                      td #{post.content}
                      td #{post.date}
                      td #{post.category}  &lt;--HERE IS WHERE I NEED
                                              post.category.name
  </code></pre>