public function totalCount()
    {
        if (!isset($this->parameters['conditions'])) {
            return count($this->value);
        }

        if (!$this->totalCount) {
            if (is_callable($this->totalCountCalculation)) {
                $this->totalCount = ($this->totalCountCalculation)();
            } else {
                $mongo = Entity::getInstance()->getDatabase();
                $entity = $this->entityClass;
                $this->totalCount = $mongo->count($entity::getCollection(), $this->parameters['conditions']);
            }
        }

        return $this->totalCount;
    }