ModelBundle/Repository/NodeRepository.php
public function countBlockUsed($blockId)
    {
        $qb = $this->createQueryBuilder();
        $function = new \MongoCode(
            'function() {
                for (var areaIndex in this.areas)
                    for (var key in this.areas[areaIndex].blocks)
                        if (this.areas[areaIndex].blocks[key].$id == "'.$blockId.'")
                            return this;
            }'
        );
        $qb->where($function);

        return $qb->getQuery()->execute()->count();
    }
public function countBlockUsed($blockId)
    {
        $qb = $this->createQueryBuilder();
        $function = new \MongoCode(
            'function() {
                for (var areaIndex in this.areas)
                    for (var key in this.areas[areaIndex].blocks)
                        if (this.areas[areaIndex].blocks[key].$id == "'.$blockId.'")
                            return this;
            }'
        );
        $qb->where($function);

        return $qb->getQuery()->execute()->count();
    }
@param string $blockId

@return boolean