It's probably not the best way to achieve this, but it does work:
$qb = $om->createQueryBuilder(FormService::ENTITY_CLASS_NAME_FORM);
$query = $qb->field('website.$id')->equals(new \MongoId($website->getId()))
->field('status.name')->equals(FormService::STATUS_PUBLISHED)
->field('eventListeners.0')->exists(true)
->getQuery();
$results = $query->execute();
This assumes that it is a 0 based index Collection
and not a Hash
.
I realise you can do DB.find({eventListeners: {$not: {$size: 0}}})
in mongo, but I'm not sure how to properly structure it in the ODM query builder.
After reviewing the odm documentation I'm not sure if it's even possible to do.
The other approach is to use a $where
function: http://docs.mongodb.org/manual/reference/operator/query/where/