{
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;
$newReview = [
user_name => "Michael",
date => new \MongoDB\BSON\UTCDateTime( new DateTimeImmutable("2017-02-02") ),
note => "No peat, but fruity",
rating => 1,
];
$whisky->updateOne(
[ 'name' => 'Glenfiddich 15' ],
[ '$push => [ 'notes' => $newReview ] ]
);
?>