A document contains an array of object each object contains a key i want to find all the object that matches the key in mongoose. Below is the sample schema:
const TalentSchema = new mongoose.Schema({
name: String,
  dev_task: [
        {
          development_training: {
            type: mongoose.Schema.Types.ObjectId,
            ref: 'TrainingModule',
          },
          developlink: String,
        },
      ],  
})
I want to match the document that have development_training to given Id. How can i do that ?
Update : Sample Data
[
  {
    "name": "name1",
    "dev_task": [
      {
        "development_training": 1,
        "developlink": ""
      },
      {
        "development_training": 2,
        "developlink": ""
      }
    ]
  },
  {
    "name": "name2",
    "dev_task": [
      {
        "development_training": 1,
        "developlink": ""
      }
    ]
  },
]
It should return This : -
[
  {
    "_id": ObjectId("5a934e000102030405000000"),
    "dev_task": [
      {
        "developlink": "",
        "development_training": 1
      }
    ],
    "name": "name1"
  },
  {
    "_id": ObjectId("5a934e000102030405000001"),
    "dev_task": [
      {
        "developlink": "",
        "development_training": 1
      }
    ],
    "name": "name2"
  }
]
 
    