<?php
namespace MyVendor\MongoBundle\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
/**
* @MongoDB\Document(repositoryClass="MyVendor\MongoBundle\Repository\UserRepository")
*/
class User
{
/**
* @MongoDB\Id
*/
private $id;
/**
* @var
* @MongoDB\ReferenceOne(targetDocument="Group", inversedBy="users")
*/
private $group;
/**
* Set group
*
* @param MyVendor\MongoBundle\Document\Group $group
* @return User
*/
public function setGroup(\MyVendor\MongoBundle\Document\Group $group)
{
$this->group = $group;
$group->addUsers($this);
return $this;
}
}
SELECT COUNT(c.id) CountOfComments
FROM comments
WHERE c.record_id IN (... IDS ...)
GROUP BY c.record_id
В IN просто перечисляете ID записей, полученных из 1-го запроса.