how to group sub array inside document using mongodb

hi, i have the following document on mongodb

name: "john",
state: "GA",
city: [
     {"atlanta", 30350},
     {"atlanta", 30351},
     {"atlanta", 30352},
     {"marietta", 45093}
]


how do i aggregate the array of citys and get a document like this:

name: "john",
state: "GA",
city: [
     {"atlanta", "30350, 30351, 30352"},
     {"marietta", "45093"}
]
LVL 1
rafaelrglAsked:
Who is Participating?
 
rafaelrglAuthor Commented:
{ $concatArrays: [ [ "hello", " "], [ "world" ] ] }
0
 
Nitin SontakkeDeveloperCommented:
I am almost certainly (not yet) an expert on MongoDB, however, I suspect if you can do that without getting data back, manipulate it and put it back again.

How many records (Ooops! documents) are involved here? Please wait for others to comment as well.
0
 
rafaelrglAuthor Commented:
that is the right solution for it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.