updated: 2018/10/23
環境: Laravel 5.7.6 PHP7
特定のコレクション内のcomments array の特定の _id をもつバリューを削除したい。
$db = (new MongoDB\Client)->YOUR_DB;
$collection = $db->YOUR_COLLECTION;
$pid は削除したい pixieImage collection の id
$cid は削除したいcomment の id 下記例ではcommentsの一番目の_id
MongoDB\BSON\ObjectId を自前で作るなら
use MongoDB;
参考:
MongoDB\Collection::updateOne() — PHP Library Manual 1.4
https://docs.mongodb.com/manual/reference/operator/update/pull/index.html
PHP: MongoDB\BSON\ObjectId - Manual
https://docs.mongodb.com/php-library/current/reference/method/MongoDBCollection-findOne/