I'm trying to remove the field from the teacher array that contains a specific subject, such as "ok baby"
{
"_id" : "billy",
"password" : "$2a$10$MKZFNtMhts6rMbnIoqXB9.Q8NHAizQAGhX5S6g.8zeRt7TpRpuQea",
"teacher" : [
{
"subject" : "ok baby",
"students" : [
"billy"
]
},
{
"subject" : "adsfqewr",
"students" : [
"billy"
]
}
]
}
This is what I tried:
users.update( { 'teacher.subject':title, '_id':username},
{ $pull: { 'teacher.subject':title } },
{ multi: true }
)