I'm unable to sort the embedded document. Here is my code.
Children.php
namespace Acme\CCBundle\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
/**
* @MongoDB\Document
*/
class Children {
/..
/**
* @MongoDB\EmbedMany(targetDocument="Vaccine")
*/
protected $vaccine = array();
}
Vaccine.php
namespace Acme\CCBundle\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
/**
* @MongoDB\EmbeddedDocument
*/
class Vaccine
{
/**
* @MongoDB\Date
*/
protected $recordDate;
/**
* @MongoDB\String
*/
protected $vaccineName;
}
In my controller: RecordController.php
public function showVaccineAction($id) {
$child = $this->get('doctrine_mongodb')
->getRepository('AcmeCCBundle:Children')
->find($id);
$vac = $child->getVaccine();
return $this->render(
'AcmeCCBundle:Record:show_vaccine.html.twig', array('vac' => $vac)
);
}
I just be able query all the vaccine of a child, and it's not ordered. Can anybody help me?