Description
I appreciate this is probably a little bit of an odd use-case, but its something I'm struggling with and would love it if someone had an idea which might help.
The issue I have is that I'm trying to integrate ODM on top of a legacy system which has documents stored where the embedded document can be either an object (in the case where there was only one) or an array (in the case where there was many). For reasons I won't go in to, migrating or altering the legacy system which creates these documents is not an option.
I've got a document set up as so:
class Competition
{
/**
* @MongoDB\EmbedMany(targetDocument="TeamStanding", name="TeamStandings")
*/
private $teamStandings = [];
/**
* @MongoDB\EmbedOne(targetDocument="TeamStanding", name="TeamStandings")
*/
private $teamStanding;
Because these are both linked to the same json node TeamStandings
, only one takes effect. For reference the document structure looks something like:
{
"TeamStandings": {
// team standing
}
}
or
{
"TeamStandings": [
{
// team standing 1
},
{
// team standing 2
}
}
It seems like I need something like an "EmbedManyOrOne" annotation! All and any suggestions are appreciated.