How to add same fields from different collection of same db in Charts

I am trying to draw some MongoDB Charts, I have a db called user_activities with user based collections, each collection has field called count, now I need to write a single chart which can show the total count of user activities from all user collections, I tried below query in query tab but getting below error

(BadValue) unknown top level operator: $lookup

        from: "name_123",      
        localField: "count",  
        foreignField: "name_345.count",  
        as: "SingleCount"         

How to give multiple collections of same db in single chart for some aggregation or count ?

Hi @Great_Info -

You’re on the right track, just a couple of things you need to do:

  1. Today, you can only use $lookup from a data source pipeline - you can’t do this in the chart builder query bar. You can add a data source pipeline by clicking “Add Pipeline” from the Data Sources page.
  2. Aggregation stages need to be defined in an array (even if there’s just once stage) so make sure you wrap the entire thing in square brackets.



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