What If a want to group some properties on a nested object.
resultMaps = [
{
mapId: 'teamMap',
idProperty: 'id',
properties: ['name'],
associations: [
{ name: 'players', mapId: 'playerMap', columnPrefix: 'player_' }
]
},
{
mapId: 'playerMap',
properties: ['name']
}
]
resultSet = [
{ team_id: 1, team_name: 'New England Patriots', player_name: 'Tom Brady' }
];
mappedResult = joinjs.map(resultSet, resultMaps, 'teamMap', 'team_');
expect(mappedResult).to.deep.equal [
{
id: 1
name: 'New England Patriots'
player: {
name: 'Tom Brady'
}
}
]