How to set property undefined in nested array of nested object

{
    _id: "xPBc4By8FemDwTPqH",
    friends: [{
        username: "michael",
        friendid: "154879",
        friendlist: [{
            randid: 54685,
            friendname: "john",
            illustrations: [{
                randid: 178432,
                image: "friend1.jpg"
            }, {
                randid: 545457,
                image: "friend2.jpg"
            }]
        }]
    }]
}

My database structure looks like this. I want to pull a particular image in the illustrations array. I tried this code:

Collections.user.update(
    { "friends.friendid": 154879} ,
    { $pull: { 'friends.$[].friendlist.$[].illustrations':  { "image": req.body.image  } } } ,
    function(err,result) {
        if (err)
            console.log(err);
        else
            res.send("Deleted");
  })

This query is working but deletes the entire object instead of just deleting the filtered image. Another option I’ve tried is to set image = undefined, but it didn’t work either.

Can someone help me, please?

Does it log any error?

Stackoverflow may provide you with lots of info:

MongoDB - Update an object in nested Array