I have an object with these properties :
{
    title: 'Test',
    places: [
      {
        id: 1,
        longitude: 48.8469511,
        latitute: 2.3077989,
        address: 'Pont de Bir-Hakeim',
        city: {name: 'Paris', id: 1}
      },
      {
        id: 2,
        longitude: 48.855225,
        latitute: 2.288048,
        address: 'Palais-Musée Galliera, 10 avenue Pierre-1er-de-Serbie',
        city: {name: 'Paris', id: 1}
      },
      {
        id: 3,
        longitude: 50.8283315,
        latitute: -115.2608429,
        address: 'Fortress Moutain',
        city: {name: 'Calgary', id: 2}
      }
    ]
}
Here is the result I want :
[
  {
    id: 1,
    name: 'Paris'
  },
  {
    id: 2,
    name: 'Calgary'
  },
]
How can I achieve that by using groupBy map reduce ?
Here is what I tried :
   return from(movie.places).pipe(
      groupBy(place => place.city.name),
      mergeMap(place => place.pipe(map(obj => obj.city.name))),
      toArray()
   );
Which produce :
['Paris', 'Paris', 'Calgary']
It's not very clear in my head on how to use groupBy, map, mergeMap, toArray together...
Thanks for the help!
 
     
    