public function findOne(array $query = [], bool $normalizeDates = true)
    {
        if ($normalizeDates) {
            $query = $this->normalizeDates($query);
        }

        //Working with projection (required to properly sort results)
        $result = $this->collection->findOne(
            array_merge($this->query, $query),
            $this->createOptions()
        );

        if (empty($result)) {
            return null;
        }

        return $this->odm->make($this->class, $result, false);
    }
public function findOne(array $query = [], bool $normalizeDates = true)
    {
        if ($normalizeDates) {
            $query = $this->normalizeDates($query);
        }

        //Working with projection (required to properly sort results)
        $result = $this->collection->findOne(
            array_merge($this->query, $query),
            $this->createOptions()
        );

        if (empty($result)) {
            return null;
        }

        return $this->odm->make($this->class, $result, false);
    }
public function findOne ( array $ query = [ ] , bool $ normalizeDates = true ) { if ( $ normalizeDates ) { $ query = $ this -> normalizeDates ( $ query ) ; } //Working with projection (required to properly sort results) $ result = $ this -> collection -> findOne ( array_merge ( $ this -> query , $ query ) , $ this -> createOptions ( ) ) ; if ( empty ( $ result ) ) { return null ; } return $ this -> odm -> make ( $ this -> class , $ result , false ) ; }
Select one document or it's fields from collection.

Attention, MongoDB is strictly typed!

@param array $query          Fields and conditions to query by. Query will not be added to an
existed query array.
@param bool  $normalizeDates When true (default) all DateTime objects will be converted into
MongoDate.

@return CompositableInterface|null
Select one document or it s fields from collection .