Answers for "bulk write mongodb php"

PHP
0

bulk write mongodb php

<?php

$bulk = new MongoDBDriverBulkWrite;

$document1 = ['title' => 'one'];
$document2 = ['_id' => 'custom ID', 'title' => 'two'];
$document3 = ['_id' => new MongoDBBSONObjectId, 'title' => 'three'];

$_id1 = $bulk->insert($document1);
$_id2 = $bulk->insert($document2);
$_id3 = $bulk->insert($document3);

var_dump($_id1, $_id2, $_id3);

$manager = new MongoDBDriverManager('mongodb://localhost:27017');
$result = $manager->executeBulkWrite('db.collection', $bulk);

?>
Posted by: Guest on October-30-2021

Browse Popular Code Answers by Language