Grouping values ​​with the same column together and getting all fields.

My data model is like below:

[
  {
    "a": 123,
    "b": 0,
    "c": "test0"
  },

  {
    "a": 123,
    "b": 1,
    "c": "test1"
  },

  {
    "a": 234,
    "b": 0,
    "c": "test3"
  },

  {
    "a": 234,
    "b": 1,
    "c": "test4"
  },

]

I want to group the values having the same value like this:


[
  123: [
  {
    "a": 123,
    "b": 0
    "c": "test0"
  },
  {
    "a": 123,
    "b": 1,
    "c": "test1"
  },
  ]

  234: [
    {
    "a": 234,
    "b": 0,
    "c": "test3"
  },

  {
    "a": 234,
    "b": 1,
    "c": "test4"
  },
  ]

]

Hey @drh0use!

Are you referring to the output when you run a N1QL query?

Cheers!

SELECT b.a, ARRAY_AGG(b) AS vals
FROM mybucket AS b
WHERE b.a IS NOT NULL
GROUP BY b.a