示例#1
0
 /**
  * 
  * @param \com\bazaar\core\mongom\QueryObject $query
  * @return \com\bazaar\core\mongom\aggregationframework\Aggregate
  * 
  * @todo handle text
  */
 public function match(mongom\QueryObject $query)
 {
     $this->pipeline[]['$match'] = $query->getQuery();
     $this->lastOperation = Aggregate::OPS_MATCH;
     return $this;
 }
示例#2
0
 /**
  * 
  * @param core\Model $updateModels
  * @param QueryObject $queryObject
  * 
  * Only valid for cleaned object laoded from DB
  * 
  * @todo Update now onl;y handles list collection using $pushAll. Update will be made
  *  to mae support set collection using $addToSet
  * 
  */
 public function update(core\Model $updateModel, QueryObject $queryObject = NULL, $options = [])
 {
     // xdebug_var_dump("Update new objects " . $updateModels->count());
     $updateModelSerialized = [];
     $modelMap = new MongOM($updateModel);
     $data = $this->prepareSave($updateModel, $options);
     //xdebug_var_dump('Data' ,$data);
     //xdebug_var_dump($modelMap->getProperties());
     /*
      * @todo Replace flag
      * If REPLACE flag is off
      * Remove mongo id
      */
     unset($data['_id']);
     $collectionFields = array_filter($data, function ($value) {
         //xdebug_var_dump($value,is_array($value));
         return is_array($value);
     });
     $singularFields = array_diff_key($data, $collectionFields);
     //xdebug_var_dump($collectionFields,$singularFields);
     $updateModelSerialized = ['$set' => $singularFields, '$pushAll' => $collectionFields];
     //xdebug_var_dump($updateModelSerialized,$queryObject->getQuery());
     /*
      * @todo will be removed when untiofworker will be chnaged.
      * Commits will be made from unitof work
      */
     $collection = $modelMap->getEntity();
     //xdebug_var_dump($collection);
     $updatestatus = $this->connection->{$collection}['name']->update($queryObject->getQuery(), $updateModelSerialized, $options);
     // xdebug_var_dump($queryObject->getQuery(),$updatestatus);
 }