Mongolid\DataMapper\DataMapper::first PHP Метод

first() публичный Метод

Retrieve one $this->schema->entityClass objects that matches the given query.
public first ( mixed $query = [], array $projection = [], boolean $cacheable = false ) : mixed
$query mixed MongoDB query to retrieve the document.
$projection array Fields to project in Mongo query.
$cacheable boolean Retrieves the first through a CacheableCursor.
Результат mixed First document matching query as an $this->schema->entityClass object
    public function first($query = [], array $projection = [], bool $cacheable = false)
    {
        if ($cacheable) {
            return $this->where($query, $projection, true)->first();
        }
        $document = $this->getCollection()->findOne($this->prepareValueQuery($query), ['projection' => $this->prepareProjection($projection)]);
        $document = Ioc::make(Converter::class)->toDomainTypes((array) $document);
        if (!$document) {
            return;
        }
        $model = $this->getAssembler()->assemble($document, $this->schema);
        return $model;
    }