Monday 13 March 2017

MongoDB - Multiple query and single document result

I'm creating an insights dashboard and I have some many data and stored count of this but I need consolidate this in one document. (umm is hard to explain in words), e.g.

Site collection:

{
 Name: "..."
 ApiKey: "SomeUnique1"
 Insights:
 {
   sumOfData: 5,
   anotherSum: 14
 }
},
{
     Name: "..."
     ApiKey: "SomeUnique2"
     Insights:
     {
       sumOfData: 5,
       anotherSum: 1
     }
    },...

I want to retrieve next following data:

{
     ChartDashboard: "Usage"
     Insights:
     {
       sumOfData: 10,
       anotherSum: 15
     }
    }

I read that $and operator can retrieve with some ApiKey's properties, but MongoDB have any operator to make this?



via Cami Rodriguez

No comments:

Post a Comment