Example #1
0
 /**
  * Update record by PK
  * @param string|MongoId $pk
  * @param array $updateDoc
  * @param array|EMongoCriteria $criteria
  * @param array $options
  * @return bool
  */
 public function updateByPk($pk, $updateDoc = [], $criteria = [], $options = [])
 {
     $this->trace(__FUNCTION__);
     if (!$criteria instanceof Query) {
         $criteria = new Query(['condition' => $criteria]);
     }
     $criteria->parseOptions($options);
     $criteria->andCondition([$this->primaryKey() => $this->getPrimaryKey($pk)]);
     $result = $this->getCollection()->updateOne($criteria->getCondition(), $updateDoc, $criteria->getOptions());
     return $result;
 }