MongoDB sum values in document

I'm making an application with MongoDB and C#. I use the MongoDB driver.

{
     _id: ObjectId("5099803df3f4948bd2f98391"),
     Title: "Test",
     Rating: {
          1234 : 4.0,
          4689 : 2.5,
          1987 : 1.5
     }
}

Now I want to get the average rating. So (4.0+2.5+1.5) / 3. But how do I do this with MongoDB and the C# driver. I'm trying to unwind and then count. But it's not working.

#c-sharp #mongodb

3 Likes1.75 GEEK