2021-10-29

Nested grouping in Mongodb

I am working on grouping the MongoDB documents and updating the sample in the below link

https://mongoplayground.net/p/c2s8KmavPBp

I am expecting the output to look like

[
  {
    "group" : "one",
      "details":[{
        "avgtime" : 9.359833333333333,
        "title": "Scence 1"
    },{
        "avgtime" : 9.359833333333333,
        "title": "Scence 2"
    },{
        "avgtime" : 9.359833333333333,
        "title": "Scence 3"
    }]
  },
  {
    "group" : "two",
      "details":[{
        "avgtime" : 9.359833333333333,
        "title": "Scence 1"
    }]
  }
  ]

How to rename the field _id to the group and merge the two elements containing title: scence 1 and display their average time

Note: Question and sample link updated



from Recent Questions - Stack Overflow https://ift.tt/3CpskD7
https://ift.tt/eA8V8J

No comments:

Post a Comment