removing object from nested array of objects mongodb

Viewed 2292

I've got collection with volunteer information in it, and it lists the volunteers as an array of objects. I can display all the shifts for each volunteer, but removing one from the array is proving difficult for me:

Sample data:

"_id" : ObjectId("59180305c19dbaa4ecd9ee59"),
    "where" : "Merchandise tent",
    "description" : "Sell gear at the merchandise tent.",
    "shifts" : [
            {
                    "dateNeeded" : ISODate("2017-06-23T00:00:00Z"),
                    "timeslot" : "8:00 - NOON",
                    "needed" : 2,
                    "_id" : ObjectId("591807546a71c3a57d1a2105"),
                    "volunteers" : [
                            {
                                    "fullname" : "Mary Mack",
                                    "phone" : "1234567890",
                                    "email" : "mary@gmail.com",
                                    "_id" : ObjectId("591ce45bc7e8a8c7b742474c")
                            }
                    ]
            },

The data I have available for this is: _id, where, shifts.timeslot, shifts.dateNeeded, volunteers.email

Can someone help me? Lets say Mary Mack wants to unVolunteer for the 8 - Noon shift at the merchandise tent. She may be listed under other shifts as well, but we only want to remove her from this shift.

2 Answers
Related