无法在MongoDB集合中将新数据追加到现有文档

时间:2018-07-19 10:59:01

标签: php mongodb

我尝试使用php输入重量和墨水字段以及相关数据。但这给出了“某些错误”错误消息。我想做的是要向选定的现有mongoDB文档中添加权重和墨水字段

$insRec       = new MongoDB\Driver\BulkWrite;
$insRec->update(['id'=>new MongoDB\BSON\ObjectID($b['$oid'])],['$push' =>['ink' =>$ink, 'weight'=>$weight]], ['multi' => false, 'upsert' => false]);
$writeConcern = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, 1000);
$result = $manager->executeBulkWrite('sampledb.style', $insRec, $writeConcern);
print_r($result);
   if($result->getModifiedCount()){
       echo "OK";
    }else{
            echo "Something Wrong";

0 个答案:

没有答案