I have a mongo collection like so:
{
_id: 'asdasdasd',
battletag: 'battletag#1290',
games: [{
id: "somegameid",
name: "Starcraft II",
characters: ['corvid'],
groups: ['Husky Starcraft']
}, {
id: "someothergameid",
name: "World of Warcraft",
characters: ['corvid', 'crow', 'crowtoe'],
groups: ['Warlords of Draenor']
}]
}
I want to ensure that, for every game in games
, the id attribute is unique. Is there a way to ensure uniqueness on values in arrays of objects in mongodb?