mongoose populate deeply nested arrays of Objects

I want to populate contents which is deeply nested arrays of objects

My schema is :

const ClassroomSchema = new mongoose.Schema({
  name: String,
  createdBy: String,
  department: String,
  area: String,
  organization_id: {
    type: mongoose.Schema.Types.ObjectId,
    ref: "organization",
  },
  sessions: [
    {
      sessionName: String,
      topics: [
        {
          topicName: String,
          subTopics: [
            {
              subTopicName: String,
              contents: [
                {
                  type: mongoose.Schema.Types.ObjectId,
                  ref: "content",
                },
              ],
            },
          ],
        },
      ],
    },
  ],
  
});

I have tried :

 const data = await Classroom.findOne(
      {
        "sessions._id": sessionId,
        "sessions.topics._id": topicId,
        "sessions.topics.subTopics._id": subTopicId,
      })
    .populate([
      {
        path: "sessions.topics.subTopics.contents",
        select: "title url",
        model: "content",
      },
    ]);

This Results all data but empty array for contents whereas when I remove the populate function I am receiving the contents with arrays of Ids.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum