Assisting with grouping query data

The article found here was very helpful:

Here is the dataset:

City,          Population, State,  Year
Buffalo,       292000,     NY,     2000
Buffalo,       261000,     NY,     2010
Los Angeles,   3703000,    CA,     2000
Los Angeles,   3796000,    CA,     2010
Miami,         362000,     FL,     2000
Miami,         401000,     FL,     2010
New York,      8015000,    NY,     2000
New York,      8192000,    NY,     2010
Orlando,       195000,     FL,     2000
Orlando,       240000,     FL,     2010
San Diego,      1228000,    CA,     2000      
San Diego,      1306000,    CA,     2010
San Francisco, 777000,     CA,     2000
San Francisco, 805000,     CA,     2010

How can I do this?

For each unique “state”, return all “city” in that state, grouped by state.
The output would look something like this:

[
{“_id”: “FL”, “Orlando”,“Miami”},
{“_id”: “CA”, “Los Angeles”,“San Diego”,“San Francisco”},
{“_id”: “NY”, “Buffalo”,“New York”,]
]

This is the closest example on the referenced page:

wixData.aggregate(“PopulationData”)
.group(“state”)
.max(“population”)
.ascending(“populationMax”)
.run()
.then( (results) => {
let items = results.items; } );

/* items is:

  • [
  • {“_id”: “FL”, “populationMax”: 401000},
  • {“_id”: “CA”, “populationMax”: 3796000},
  • {“_id”: “NY”, “populationMax”: 8192000}
  • ]
    */

Thank you.