{
name: "Glenfiddich 15",
notes: [
{
user_name: "Derick",
date: ISODate("2013-10-02"),
note: "Caramel and honey, fruity with some hints of earth",
likes: 17,
rating: 3,
}
]
}
<?php
$whisky = new (\MongoDB\Client)->demo->whisky;
$whisky->updateOne(
[ 'name' => 'Glenfiddich 15', 'notes.user_name' => 'Derick' ],
[ '$inc => [ 'notes.$.likes' => 1 ] ]
);
?>