Query Mongodb

Hi all, I am trying to make a chart but when I query between two collections, as you can see all the row of local collection match with the first row in “from”- “Campaign” collection.


This is my following code:

[
    {
   "$lookup":
    {
       "from": "Campaign",
       "localField": "Conversion.campaign_id",
       "foreignField": "Campaign.campaign_id",
       "as":"as1"
    }
 },

 {
      "$replaceRoot": { "newRoot": { "$mergeObjects": [ { "$arrayElemAt": [ "$as1", 0 ] }, "$$ROOT" ] } }
   },
   
   { "$project": { "as1": 0 } }]

Can anyone help me this questions?

Hi @baoanhvu1806
You have asked the same question a couple of time (Query between 2 tables with Mongodb and Need help with aggregate 2 collections)
Your question does not have anything to do with Metabase, so you’ll find much better help in a MongoDB forum:
https://www.mongodb.com/community-support-resources