title: How to populate a nested object inside an array with mongoose?
body: <p>I'm trying to populate an object inside an array with Mongoose and Express, but I just get the ID as result. Does anyone know how to fix this?</p>
  <p>This is my code:</p>
  <p>Model</p>
  <pre><code>invitedEvents: [
      {
          event: {
              type: Schema.Types.ObjectId,
              ref: &quot;Event&quot;,
          },
          answer: {
              enum: [&quot;yes&quot;, &quot;maybe&quot;, &quot;no&quot;, &quot;pending&quot;],
              type: String,
          },
      },
  ],
  </code></pre>
  <p>Route:</p>
  <pre><code>router.get(&quot;/user/:id&quot;, (req, res, next) =&gt; {
      User.findById(req.params.id)
          .populate({
              path: &quot;invitedEvents&quot;,
              populate: {
                  path: &quot;event&quot;,
                  model: &quot;Event&quot;,
              },
          })
          .then(userFromDb =&gt; res.status(200).json(userFromDb))
          .catch(err =&gt; next(err))
  })
  </code></pre>
  <p>And the result:</p>
  <pre><code>answer: &quot;pending&quot;
  _id: &quot;61ffa9fa78483f59be78da72&quot;
  </code></pre>
  <p>Thanks for your help!</p>