title: Mongodb nested populate
body: <p>I have 3 collections in MongoDB with the following Schema:</p>
  <pre><code> const userSchema = new Schema({
      firstname: {
          type: String,
          trim: true
      },
      surname: {
       type: String
      }
  })
  userSchema.virtual('products', {
      ref: 'product',
      localField: '_id',
      foreignField: 'user'
  })
  
  userSchema.virtual('carts', {
      ref: 'cart',
      localField: '_id',
      foreignField: 'user'
  })
  const User = mongoose.model('user', userSchema)
  
  -----------
  
  const Product = mongoose.model('product', {
      title: {
         type: String,
         required: true
      },
      description: {
          type: String,
          required: true
      },
      quantity: {
          type: Number,
          default: -1
      },
  
      user: {
         type: Schema.Types.ObjectId,
         ref: 'user',
         required: true
      }
   })
  
  --------
  
  const ItemSchema = new Schema({
      session_id: {
          type: String
      },
      quantity: {
          type: Number,
          required: true
      },
      price: {
          type: Number
      },
      total: {
          type: Number
      },
      product: {
          type: Schema.Types.ObjectId,
          ref: 'product',
          required: true
      }
  })
  
  const CartSchema = new Schema({
      items: [ItemSchema],
      user: {
          type: Schema.Types.ObjectId,
          ref: 'user',
          required: true
      },
      total_price: {
          type: Number,
          default: 0
      }
  })
  const Cart = mongoose.model('cart', CartSchema)
  </code></pre>
  <p>So let's say we have some data in these collections and I want to get the cart data of some user like this:</p>
  <pre><code>user = await User.findById(user_id).populate({
          path: 'carts',
          populate: {
              path: 'products',
              model: 'product'
          }
      })
  return user.carts
  </code></pre>
  <p>I get the following response without giving me the product detail:</p>
  <pre><code>[
      {
          &quot;total_price&quot;: 10,
          &quot;_id&quot;: &quot;5ff373073b92a40898c50508&quot;,
          &quot;items&quot;: [
              {
                  &quot;_id&quot;: &quot;5ff4d3b86404131811e392ef&quot;,
                  &quot;product&quot;: &quot;5fe9ea426c3ff17b383dd599&quot;,
                  &quot;quantity&quot;: 5,
                  &quot;price&quot;: 2,
                  &quot;total&quot;: 10,
                  &quot;createdAt&quot;: &quot;2021-01-05T21:01:44.269Z&quot;,
                  &quot;updatedAt&quot;: &quot;2021-01-05T21:01:44.269Z&quot;
              }
          ],
          &quot;user&quot;: &quot;5fe255a5543b7420c9c29c8b&quot;,
      }
   ]
  </code></pre>
  <p>How its possible to get the product detail also, and am I right with structure of the collections? Thanks</p>