src/Mapper.php
public function countObjects($type, $query = [])
    {
        $type = $this->getFullType($type);
        if (class_exists($type)) {
            $table = $type::getCollection();
            return $this->mongodb->$table->find($query, ['_id' => true])->count();
        }
        return false;
    }
public function countObjects($type, $query = [])
    {
        $type = $this->getFullType($type);
        if (class_exists($type)) {
            $table = $type::getCollection();
            return $this->mongodb->$table->find($query, ['_id' => true])->count();
        }
        return false;
    }
public function countObjects ( $ type , $ query = [ ] ) { $ type = $ this -> getFullType ( $ type ) ; if ( class_exists ( $ type ) ) { $ table = $ type :: getCollection ( ) ; return $ this -> mongodb -> $ table -> find ( $ query , [ '_id' => true ] ) -> count ( ) ; } return false ; }
Count objects in collection matching Mongo query
@param string $type Name of class of objects that should be counted
@param array $query Mongo select query, only objects matching it are counted
@return mixed number of objects matching query or false if class $type does not exist
Count objects in collection matching Mongo query