Store the new document in the given category.

@param  Document  $document  The document to store.
@return  document  Returns the document.
503730
public function storeDocument(\Document $document)
  {
    $arrSet = $this->buildDocumentDataArray($document, false);
    
    $objDocument = $this->Database->prepare("INSERT INTO tl_dms_documents %s")->set($arrSet)->execute();
    
    $document->id = $objDocument->insertId;
    return $document;
  }
1236000
public function references($document)
    {
        if ($this->currentField) {
            $mapping = $this->class->getFieldMapping($this->currentField);
            $dbRef = $this->dm->createDBRef($document, $mapping);

            if (isset($mapping['simple']) && $mapping['simple']) {
                $this->query[$mapping['name']] = $dbRef;
            } else {
                $keys = array('ref' => true, 'id' => true, 'db' => true);

                if (isset($mapping['targetDocument'])) {
                    unset($keys['ref'], $keys['db']);
                }

                foreach ($keys as $key => $value) {
                    $this->query[$this->currentField . '.$' . $key] = $dbRef['$' . $key];
                }
            }
        } else {
            $dbRef = $this->dm->createDBRef($document);
            $this->query = $dbRef;
        }

        return $this;
    }
345192
public function store(CategoryRequest $request)
    {
        $category = Category::create($request->all());

        return (new CategoryResource($category));
    }
489610
public function add(SolrDocument $document)
    {
        $result = $this->request(
            'POST',
            $this->getCore() . '/update/json',
            [],
            [
                'add' => [
                    'doc' => $document->toArray()
                ]
            ]
        );

        if ($this->isAutoCommit()) {
            $this->commit();
        }

        return $result;
    }
1218740
public function setDocumentData(array $document)
    {
        $this->set('__date__', new \MongoDate);
        $this->set('__documentId__', $document['_id']);
        
        unset($document['_id']);
        
        $this->merge($document);
        
        
        return $this;
    }
1320924
public function setDocument(Document $document): self
    {
        $this->_data = $document;

        $metadata = $this->_getMetadata($document);

        $this->setMetadata($metadata);

        return $this;
    }
1342979
public function insert($document)
    {
        $class     = $this->dm->getClassMetadata(get_class($document));
        $changeset = $this->uow->getDocumentChangeSet($document);
        $qb        = $this->dm->createQueryBuilder($this->class->name);

        foreach ($class->propertyMetadata as $mapping) {
            $new = isset($changeset[$mapping->name][1]) ? $changeset[$mapping->name][1] : null;

            if (($new === null && !$mapping->nullable) || $mapping->isInverseSide) {
                continue;
            }

            if ($mapping->isMany()) {
                if ($mapping->strategy === PropertyMetadata::STORAGE_STRATEGY_ADD_TO_SET || $new->isEmpty()) {
                    continue;
                }

                $this->uow->unscheduleCollectionDeletion($new);
                $this->uow->unscheduleCollectionUpdate($new);
            }

            $qb->attr($mapping->name)->put($new);
        }

        //add a conditional preventing the resulting PutItem from overwriting
        //an existing record with the same primary key
        $class->createIdentifier($document)->addNotExistsToQueryCondition($qb->expr);

        $qb->getQuery()->execute();
    }
196601
public function addDocumentToDocumentPool(Document $document)
    {
        $documentId = (string) $document->getId();

        if (!isset($this->documentPool[$documentId])) {
            $this->documentPool[$documentId] = $document;
        } else {
            // merging because document after
            // load and before getting in second place may be changed
            // and this changes must be preserved:
            //
            // 1. Document loads and modifies in current session
            // 2. Document loads modified in another session
            // 3. Document loads once again in current session. Changes from stage 2 merges as unmodified

            $this->documentPool[$documentId]->mergeUnmodified($document->toArray());
        }

        return $this;
    }
1119904
public function getDocumentActualData(object $document) : array
    {
        $class      = $this->dm->getClassMetadata(get_class($document));
        $actualData = [];
        foreach ($class->reflFields as $name => $refProp) {
            $mapping = $class->fieldMappings[$name];
            // skip not saved fields
            if (isset($mapping['notSaved']) && $mapping['notSaved'] === true) {
                continue;
            }
            $value = $refProp->getValue($document);
            if ((isset($mapping['association']) && $mapping['type'] === 'many')
                && $value !== null && ! ($value instanceof PersistentCollectionInterface)) {
                // If $actualData[$name] is not a Collection then use an ArrayCollection.
                if (! $value instanceof Collection) {
                    $value = new ArrayCollection($value);
                }

                // Inject PersistentCollection
                $coll = $this->dm->getConfiguration()->getPersistentCollectionFactory()->create($this->dm, $mapping, $value);
                $coll->setOwner($document, $mapping);
                $coll->setDirty(! $value->isEmpty());
                $class->reflFields[$name]->setValue($document, $coll);
                $actualData[$name] = $coll;
            } else {
                $actualData[$name] = $value;
            }
        }
        return $actualData;
    }
512224
public function getNodeForDocument($document)
    {
        $oid = $this->getObjectIdentifier($document);
        $this->assertDocumentExists($document);

        return $this->nodeMap[$this->documentNodeMap[$oid]];
    }
496530
public function setDocument($doc)
    {
        $this->clearDocument();
        $doc = json_decode(json_encode($doc)); // ensure we are working with an object

        // set known properties
        if (!empty($doc->version)) {
            $this->version = $doc->version;
        }
        if (!empty($doc->href)) {
            $this->href = $doc->href;
        }
        if (!empty($doc->scope)) {
            $this->scope = $doc->scope;
        }
        if (!empty($doc->attributes)) {
            $this->attributes = $doc->attributes;
        }
        if (!empty($doc->links)) {
            $this->links = $doc->links;
        }
        if (!empty($doc->items)) {
            $this->items = $doc->items;
        }
        if (!empty($doc->errors)) {
            $this->errors = $doc->errors;
        }

        // get/set static links (preserving them between sets)
        foreach (self::$_staticLinkNames as $name) {
            if (empty($this->links->$name)) {
                $this->links->$name = self::$_staticLinks->$name;
            } else {
                self::$_staticLinks->$name = $this->links->$name;
            }
        }
        return $this;
    }
1337146
public function init(Document $document)
	{
		$this->title = $document->getTitle();
		$this->address = $this->getAddress($document, $this->serviceLocator);
		
		return $this;
	}
442056
public function setDocument(\Neobazaar\Entity\Document $document = null)
    {
        $this->document = $document;
    
        return $this;
    }
469308
public function store(DocumentInterface $document)
    {
        $id = $document->getId();

        // Generate an id if none has been defined
        if (is_null($id)) {
            $id = $document->setId($this->generateId());
        }

        if (!$this->validateId($id)) {
            throw new \Exception(sprintf('`%s` is not a valid document ID.', $id));
        }

        $path = $this->getPathForDocument($id);
        $data = get_object_vars($document);
        $data = $this->formatter->encode($data);

        if(!$this->write($path, $data)) {
            return false;
        }

        return $id;
    }
356324
public function persist(Document $document)
    {
        $this->pool->attach($document, self::STATE_SAVE);

        return $this;
    }
514661
public function createIdentifier($document, $unmarshal = false)
    {
        $index     = $this->getIndex();
        $hashKey   = $index->getHashKey();
        $hashValue = $hashKey->getPropertyMetadata()->getValue($document);

        if ($unmarshal) {
            $hashValue = $hashKey->getType()->convertToPHPValue($hashValue);
        }

        if (!$index->isComposite()) {
            return $this->createIdentifierFromValues($hashValue);
        }

        $rangeKey   = $index->getRangeKey();
        $rangeValue = $rangeKey->getPropertyMetadata()->getValue($document);

        if ($unmarshal) {
            $rangeValue = $rangeKey->getType()->convertToPHPValue($rangeValue);
        }

        return $this->createIdentifierFromValues($hashValue, $rangeValue);
    }
1240570
public function addDocument(\Innova\CollecticielBundle\Entity\Document $documents)
    {
        $this->documents[] = $documents;

        return $this;
    }