Dealing with arrays in aggregation

Поділитися
Вставка
  • Опубліковано 6 лют 2025
  • In this MongoDB aggregation pipeline tutorial, we focus on calculating the average number of tags per user while dealing with arrays. The challenge involves using the unwind operator to break down arrays, spreading array elements into separate documents, making it possible to calculate averages effectively. After unwinding, we utilize the group operator to group the documents by user ID and then calculate the average number of tags per user. The tutorial also introduces an alternative approach using the addFields and size operators, which simplifies the process by directly adding a new field representing the number of tags. This method avoids the need to unwind and regroup, streamlining the pipeline while achieving the same result. Both approaches are demonstrated, emphasizing the flexibility and power of MongoDB's aggregation framework for handling complex array operations.
    Welcome to a youtube channel dedicated to programming and coding related tutorials. We talk about tech, write code, discuss about cloud and devops. That’s what we do all day, all year. We roll out a lot of series and videos on our channel.
    All the learning resources such as code files, documentations, articles and community discussions are available on our website:
    chaicode.com/
    You can find our discord link, github link etc on the above website.
    Twitter/X link: x.com/hiteshdo...
    Discord link: hitesh.ai/discord
    Learn React with 10 projects: • Let's learn react from...
    Learn Docker: • A practical guide on D...
    Learn Kubernetes: • Complete Kubernetes Co...
    How does a browser works: • How does a browser wor...
    How nodejs works: • How node JS works | En...
    Learn Redux-toolkit: • Learn Redux Toolkit in...
    Learn NextJS: • Nextjs Full stack course
    Learn Typescript: • Why to learn Typescript
    Learn Javascript: • Welcome to new JavaScr...
    Learn React Native: • React Native Mastery: ...
    Learn Zustand: • React state management...
    Learn Golang: • How to get started wit...

КОМЕНТАРІ • 73

  • @xenostar3606
    @xenostar3606 Рік тому +27

    Sir this series is fantastic. Please don't get demotivated if there are less views. Keep continuing it

    • @HiteshCodeLab
      @HiteshCodeLab  Рік тому +21

      I will try my best

    • @vaibhavdani4470
      @vaibhavdani4470 7 місяців тому

      Legends doesn't care about views. They simply do their Job at its best !!

  • @samirandas8388
    @samirandas8388 2 місяці тому

    In my internship, my team lead told me that we are going to use the aggregation pipeline. Thanks, sir, for this resource.

  • @tuhinghosh9737
    @tuhinghosh9737 5 місяців тому +1

    Confused when watch this for the first time, after watching it twice now everything is clear ❤

  • @khushaldhale1788
    @khushaldhale1788 Рік тому +6

    Best Series for Aggregation ,Thank You Hitesh Sir

  • @shubhamrathod9249
    @shubhamrathod9249 10 місяців тому +2

    Yes I'm enjoying this scenario based learning. Thank you for the efforts!

  • @AdityaZom
    @AdityaZom Місяць тому

    Love you so much bro, absouletly loving the series

  • @MdShihabUddin-dh5vc
    @MdShihabUddin-dh5vc Рік тому +2

    Thanks everything ❤️,
    Not stop this type of tutorial.
    We need this type of tutorial more.

  • @asmittyagi6250
    @asmittyagi6250 10 місяців тому +1

    Merci, monsieur.

  • @anandshinde0358
    @anandshinde0358 11 місяців тому +1

    Thank you sir for best series ❤❤❤❤❤

  • @ArihantJain-h3o
    @ArihantJain-h3o Рік тому +1

    Seriously this series is truly helpful great content!

  • @Rahul-jo1mp
    @Rahul-jo1mp 8 місяців тому +2

    Landed here just after completing "Chai-aur-Backend" Series

  • @maximus-the-merciful
    @maximus-the-merciful 7 днів тому

    Hi! Great series. Like!! Subscribed a long time ago.

  • @bytequest1552
    @bytequest1552 Рік тому +2

    Your intutive and application based way of teaching inspires me, great series. Just one question that I have, I feel strong connections between sql queries and aggregation pipelines, I see that they do similar work but, for different types of DBMS

  • @RahulJhaJourney
    @RahulJhaJourney 6 місяців тому +1

    Thank you for making this series.

  • @hussainsharif1186
    @hussainsharif1186 28 днів тому

    13:40 I do njoyed a lot sir

  • @amankch
    @amankch Рік тому +3

    Awesome and engaging series.

  • @Solo_playz
    @Solo_playz 9 місяців тому

    That's very deep 😮 Thank you sir for such an informative and deeply concentrated video on Mongo aggregations ❤❤

  • @amitkumargouda1768
    @amitkumargouda1768 Рік тому

    Scenarios-based learning is awesome...Easy to grasp

  • @varunraj1823
    @varunraj1823 Рік тому +2

    Thank you for the amazing series sir

  • @CodeKiKitab
    @CodeKiKitab 11 місяців тому

    finally complete my backend knowledge with series ThankYou So much Sir

  • @ujjwaldhiman7129
    @ujjwaldhiman7129 Рік тому +1

    Great series as told by sir only for target audience who knows aggregation worth❤❤❤

  • @virgarg1012
    @virgarg1012 7 місяців тому

    Great Content !!! Loved it

  • @vedanshbisht1309
    @vedanshbisht1309 7 місяців тому

    Hey hitesh great video , very in depth and useful. Just one thing how would I be using these pipelines as an API for my application ?

  • @shehza-d
    @shehza-d Рік тому +1

    ❤‍🔥Amazing way of teaching❤‍🔥

  • @ridamsinghal1073
    @ridamsinghal1073 Рік тому +1

    Sir, this video really helps me to make my hold on MongoDB aggregation pipeline stronger. It also helps me in your video on Learn MongoDB aggregation on chai aur code. Thank you sir for this.

  • @usmanrangrez-cd7zj
    @usmanrangrez-cd7zj 9 місяців тому +1

    [
    {
    $project: {
    numberOfTags: { $size: "$tags" } // Add a field to each document representing the number of tags
    }
    },
    {
    $group: {
    _id: null,
    averageTagsPerUser: { $avg: "$numberOfTags" } // Calculate the average number of tags
    }
    },
    {
    $project: {
    _id:0,
    averageTagsPerUser:1
    }
    }
    ]
    Another Way!

  • @DTALKS01
    @DTALKS01 8 місяців тому

    sir you are a GOAT - greatest of all time

  • @IshwarShelke-ep6yq
    @IshwarShelke-ep6yq 8 місяців тому

    Osm osm osm...

  • @harshgupta2752
    @harshgupta2752 Рік тому

    great series on aggregration pipeline

  • @ijasbasheer7263
    @ijasbasheer7263 25 днів тому

    thanks sir

  • @munna5553
    @munna5553 Рік тому

    Great class by great teacher 😊

  • @KamalBiswal-d9m
    @KamalBiswal-d9m Рік тому +1

    Hi Sir please do explain the transaction in mongoodb also.

  • @prateek5668
    @prateek5668 Рік тому

    Amazing series sir

  • @bonnyboben7427
    @bonnyboben7427 Рік тому

    Great video sir ♥️♥️

  • @Lguabed
    @Lguabed 4 місяці тому

    Thanks you for this video. I think only it is better to use $size of array tags instead of $unwind like that {
    $group: {
    _id: null,
    avgtags: {
    $avg: { $size : "$tags"},
    },
    },
    } it give the same result

  • @pushkarthedeveloper
    @pushkarthedeveloper 20 днів тому

    present sirji

  • @sarveshgupta1826
    @sarveshgupta1826 Рік тому +1

    Sir, Can you please combine all react native course in a single video. It would be helpful to complete in one go..😅

  • @mantragor8150
    @mantragor8150 9 місяців тому

    Your videos are amazing..............

  • @Gabriel-xq6tn
    @Gabriel-xq6tn Рік тому

    Will help me on the research of mapping NoSQL to SQL

  • @alauddinkhan6303
    @alauddinkhan6303 Рік тому

    Sir, i have an account at LCO and from past few months im not able to login and access my purchased courses. i have tried to reach out to your mail but didn't get any response. please help me in logging in.

    • @HiteshCodeLab
      @HiteshCodeLab  Рік тому

      Please visit homepage of website and use chat there. I am no longer owner of LCO

  • @HARSHKUMAR-g2d6u
    @HARSHKUMAR-g2d6u 11 місяців тому

    sir aapko agar single bhi karna ho toh aap toh paath ka bhi istemaal kar sakte hai, main kar paa raha hu sir,,,sir aapne mistake kar diya tha sir aapne opening braces lagaya but close karna bhool gaya tabhi toh woh unexpected token keh raha tha

  • @ashimmandal9920
    @ashimmandal9920 Рік тому

    should i learn dsa to apply for an internship

  • @ganeshghadage7912
    @ganeshghadage7912 18 днів тому

    Hi Sir, Thanks for series Love it ❤❤
    I have gone through the docs and I found the another possible solution for this question please check if it's correct
    [
    {
    $group: {
    _id: null,
    tagAvg: {
    $avg: {
    $size: {
    $ifNull: ["$tags", []]
    }
    }
    }
    }
    }
    ]

  • @HARSHKUMAR-g2d6u
    @HARSHKUMAR-g2d6u 11 місяців тому

    LIttle bit harder but Very Good Knowledge

  • @patelronak153
    @patelronak153 11 місяців тому

    🎉✨🚀

  • @tasnimalam6881
    @tasnimalam6881 9 місяців тому

    🎉🎉🎊🎊

  • @anand_dudi
    @anand_dudi 9 місяців тому

    thanks

  • @shivanshpatel4072
    @shivanshpatel4072 Рік тому

    Awesome

  • @sam_sharma24
    @sam_sharma24 7 місяців тому

    goldmine series

  • @erpchannel007
    @erpchannel007 11 місяців тому

  • @smsaikat9329
    @smsaikat9329 Рік тому

    ❤❤❤

  • @saquibalam7871
    @saquibalam7871 3 місяці тому

    sir please provide us the raw data please!

  • @saquibalam7871
    @saquibalam7871 3 місяці тому

    all of the data that you used

  • @lostinhimalaya9360
    @lostinhimalaya9360 Рік тому

  • @rishiraj2548
    @rishiraj2548 Рік тому

    👍💯🙏

  • @codingboy7042
    @codingboy7042 Рік тому

    Hello sir

  • @Walkerbuddy
    @Walkerbuddy 10 місяців тому

    aaaaaa

  • @Walkerbuddy
    @Walkerbuddy 10 місяців тому

    ddddd

  • @leeladharsuthar2152
    @leeladharsuthar2152 Рік тому