I need to do this schema in symfony2 with odm, I have problems because the relasion is ManyToMany and I dont know How to do this. I need help. I have the entity "Persona" and entity "Direccion" and these generate the entity "Persona-has-Direccion" with his ids and the attribute "viveAqui".
Persona{
_id: 1000,
nombre: 'Carlos',
apellidos: 'Gracia',
genero: 'M',
direcciones: [{
direccion_id: 1,
viveAqui: true
}.{
direccion_id: 2,
viveAqui: true
}]
}
My code:
/**
* @MongoDB\Document
*/
class Direccion
{
/**
* @MongoDB\Id(strategy="auto")
*/
private $id;
/**
* @MongoDB\String
*/
private $pais;
/**
* @MongoDB\String
*/
private $estado;
/**
* @MongoDB\String
*/
private $ciudad;
/**
* @MongoDB\Boolean
*/
private $viveAqui;
}
/**
* @MongoDB\Document
*/
class Persona
{
/**
* @MongoDB\Id(strategy="auto")
*/
private $id;
/**
* @MongoDB\String
*/
private $nombre;
/**
* @MongoDB\String
*/
private $apellidos;
/**
* @MongoDB\String
*/
private $genero;
}