protected function _persist(PersistentAbstract $object)
 {
     $object->userId = \App::getUserLogged()->id;
     $this->getCache()->clean(array('list'));
     $this->getCache()->remove($object->getId());
     if ($object->getId() != null) {
         $data = $object->exportData();
         if ($data) {
             if ($this->_timestamps) {
                 $data['modified'] = time();
             }
             $data = $this->_mapModelToMongoModel($data);
             try {
                 $result = $this->getCollection()->update(array("configId" => $object->id) + $this->_defaultFilter, array('$set' => $data), $this->_updateOptions);
             } catch (\Exception $e) {
                 throw new MongoException($e->getMessage());
             }
             if ($result['n'] == 1) {
                 return $object->getId();
             }
             throw new NotFoundException(get_class($this) . ': Object not found');
         }
     }
     throw new InvalidArgumentException(get_class($this) . ': Object ID not defined.');
 }
 /**
  * @param  PersistentAbstract       $object
  * @throws NotFoundException
  * @throws InvalidArgumentException
  * @return string
  */
 public function update(PersistentAbstract $object)
 {
     if ($object->getId() != null) {
         try {
             $data = $object->exportData();
             if ($data) {
                 if ($this->_timestamps) {
                     $data['modified'] = time();
                 }
                 $data = $this->_mapModelToMongoModel($data);
                 try {
                     $result = $this->getCollection()->update(array('_id' => $object->getId()) + $this->_defaultFilter, array('$set' => $data));
                 } catch (\Exception $e) {
                     throw new MongoException($e->getMessage());
                 }
                 if ($result['n'] == 1) {
                     $this->_delete_cache($object->id);
                     return $object->getId();
                 }
                 throw new NotFoundException(get_class($this) . ': Object not found');
             }
         } catch (\Exception $e) {
             $this->_delete_cache($object->id);
             throw $e;
         }
     }
     throw new InvalidArgumentException(get_class($this) . ': Object ID not defined.');
 }