Convert the Aggregation Pipeline to rows

Hi ,

I have created an aggregation pipeline which will gives output with 3 columns and a row. How do I convert this to rows, like key value pair?

Name      Total     Count
-------   -------   -------- 
Product   5         10

I would like to display the above output as all rows

Key                Vaue
--------           --------
Name               Product
Total              5
Count              10

I tried to use the ‘$objectToArray’, tried to convert the output to array and convert them to Key value pair. I am struck in this. Please advise me the approach for this

Thanks,
Vijay

Thanks I am able to do it like below.

{
     "$project":
     {
         "one":
         {
            "Name":"$Name",
            "Total":"$Total",
            "Count":"$Count"
         }
     }
  },
  {
      "$project":
      {
      "Output": { "$objectToArray" :"$one" }
      }
  },
  {
      "$unwind": "$Output"
  }

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.