score:2

Accepted answer
 const updateActivity = (req, res) => {
    const query = { _id: req.query.id ,'classes.class': req.query.class};
    const update =  {$push:{'classes.$.activities.in_progress': req.query.data } };

    Teacher.updateOne(query,update).exec((err, data) => {
        if (err) {
            res.status(400).send({ message: err });
            return;
        } else {
            res.status(200).send(data);
        }
    })
}

score:1

const updateActivity = (req, res) => {
  const query = {
    _id: req.query.id,
    'classes.class': req.query.data,
  };
  const update = {
    $push:{ 'classes.$.activities.in_progress': req.query.data }
  };

  Teacher
    .findOneAndUpdate(query, update, options)
    .exec((err, data) => {
      if (err) {
        res.status(400).send({ message: err });
        return;
      } else {
        res.status(200).send(data);
      }
    });
}


Related Query

More Query from same tag