Sokil\Mongo\Collection::getMongoCollection PHP Method

getMongoCollection() public method

Get native collection instance of mongo driver
public getMongoCollection ( ) : MongoCollection
return MongoCollection
    public function getMongoCollection()
    {
        if (empty($this->collection)) {
            $mongoCollectionClassName = $this->mongoCollectionClassName;
            $this->collection = new $mongoCollectionClassName($this->database->getMongoDB(), $this->collectionName);
        }
        return $this->collection;
    }

Usage Example

Example #1
0
 /**
  * Find first document and update it
  *
  * @param Operator $operator operations with document to update
  * @param bool $upsert if document not found - create
  * @param bool $returnUpdated if true - return updated document
  *
  * @return null|Document
  */
 public function findAndUpdate(Operator $operator, $upsert = false, $returnUpdated = true)
 {
     $mongoDocument = $this->collection->getMongoCollection()->findAndModify($this->expression->toArray(), $operator ? $operator->toArray() : null, $this->fields, array('new' => $returnUpdated, 'sort' => $this->sort, 'upsert' => $upsert));
     if (!$mongoDocument) {
         return null;
     }
     return $this->collection->hydrate($mongoDocument, $this->isDocumentPoolUsed());
 }
All Usage Examples Of Sokil\Mongo\Collection::getMongoCollection