laravel-mongodb icon indicating copy to clipboard operation
laravel-mongodb copied to clipboard

Unset array replacing with null

Open prafful-panwar opened this issue 7 years ago • 2 comments

foreach ($event->volunteers as $key => $volunteer) { if ($volunteer['user_id'] == $userId) { $event->where('volunteers.user_id', intval($userId)) ->unset("volunteers.$key"); } }

Here is my DB structure

"volunteers" : [ null, { "user_id" : NumberInt(1), "name" : "Prafful Panwar", "skills" : [ "Plumber" ], "incentives" : { "tshirt_size" : "XXL" }, "ready_to_contribute_min_amount" : "Yes", "attendance_status" : false } ],

prafful-panwar avatar May 01 '18 06:05 prafful-panwar

Up!

FabianoLothor avatar Aug 03 '21 00:08 FabianoLothor

@prafful-panwar try to use $pull instead of $unset.

FabianoLothor avatar Aug 03 '21 02:08 FabianoLothor

Fixed by #2578

GromNaN avatar Aug 28 '23 15:08 GromNaN