Delete document from nested array in MongoDB
If you want to use the $ positional operator, you have to have matched the array items already, something like this:

db.test.update(
  {"attendance.students.studentId":{$in:[1,2,3]}},
  {$pull: {"attendance.$.students": {studentId: {$in:[1,2,3]}}}},
  {multi:true}
)


Remember that this will only update the first matching item in the attendance array in each document, so you will have to run this update more than once to make it update each attendance item.