Sokil\Mongo\Document::set PHP Method

set() public method

Update value in local cache and in DB
public set ( string $fieldName, mixed $value ) : Document
$fieldName string point-delimited field name
$value mixed value to store
return Document
    public function set($fieldName, $value)
    {
        parent::set($fieldName, $value);
        // if document saved - save through update
        if ($this->getId()) {
            $this->operator->set($fieldName, $value);
        }
        return $this;
    }

Usage Example

コード例 #1
0
 public function testSetInvalidEmbeddedDocument()
 {
     $profile = new ProfileDocument(array('name' => null));
     $document = new Document($this->collection);
     try {
         $document->set('profile', $profile);
         $this->fail('InvalidDocumentException must be thrown, but method call was successfull');
     } catch (InvalidDocumentException $e) {
         $this->assertSame(array('name' => array('required' => 'REQUIRED_FIELD_EMPTY_MESSAGE')), $e->getDocument()->getErrors());
     }
 }
All Usage Examples Of Sokil\Mongo\Document::set