MongoDB Aggregation Compass | Demo | Examples | Best Practices | Concepts

Поделиться
HTML-код
  • Опубликовано: 12 сен 2024

Комментарии • 35

  • @omega.developer
    @omega.developer 3 года назад +3

    Very clean explaination sir.
    I like your videos..!

    • @NeerajGarg
      @NeerajGarg  3 года назад +1

      Thanks a lot mahesh. Your feedback has encouraged me to put in more efforts. You may share some topic which could benefit others as well. Will try to record on that .

    • @omega.developer
      @omega.developer 3 года назад +1

      definitely @@NeerajGarg

  • @hectorrosales9417
    @hectorrosales9417 2 года назад +1

    Desde México, muchas gracias por el video me ayudo mucho, saludos.

    • @NeerajGarg
      @NeerajGarg  2 года назад

      Muchas gracias por sus comentarios. Esto realmente me ha motivado a compartir mis conocimientos con la comunidad.

  • @manjunathakotagunasi6049
    @manjunathakotagunasi6049 3 года назад +1

    Great

  • @datadriver0324
    @datadriver0324 2 года назад +1

    want to select an amount from the collection where the amount is greater than a limit(for example 10000), and the amount is in string format.

    • @NeerajGarg
      @NeerajGarg  2 года назад

      You may like to use gt and toint or convert in the MongoDB query. Sharing couple of links with you. Please go through these links once. Please don't hesitate to contact me in case the issue still persist. I would be glad to assist you. If the issue persists, please share some sample data and I'll share the query with you. Hope this helps.

  • @NanduriSree
    @NanduriSree 2 года назад +2

    How can i find the difference of Timestamp field for two documents in the given collection where msgID field is same in both documents in the same collection.

    • @NeerajGarg
      @NeerajGarg  2 года назад +1

      Hi Sreevathsava, can you please share couple of sample documents along with expected output. I'll share query with you

    • @NanduriSree
      @NanduriSree 2 года назад

      Thanks for Coming Back... Here is how my sample documents goes...
      Record 1 or Document 1
      { _id:....
      MSG_ID: 10350020304
      MSG_Status : Initiate
      Crt_TimeStamp: 2022-07-06 16:46:04:531
      MSG_SubStatus : Initiate2Stage1
      }
      Record 2 or Document 2
      { _id:....
      MSG_ID: 10350020304
      MSG_Status : Stage1
      Crt_TimeStamp: 2022-07-06 16:46:04:532
      MSG_SubStatus : Initiate2Stage1
      }
      Record 3 or Document 3, Record 4 or Document 4, Record 5 or Document 5
      Record 6 or Document 6
      { _id:....
      MSG_ID: 10350020304
      MSG_Status : Complete
      Crt_TimeStamp: 2022-07-06 16:46:04:542
      MSG_SubStatus : ProcessingDone
      }
      Sir, For a given MSG_ID in a collection, find the time difference of Crt_TimeStamp in the documents with MSG_Status : Initiate & MSG_Status : Complete.

  • @hishamahammmedkm1936
    @hishamahammmedkm1936 3 года назад +1

    thanks

  • @gamemusicmeltingpot2192
    @gamemusicmeltingpot2192 4 месяца назад +1

    after creating pipeline, how do you run it?

    • @NeerajGarg
      @NeerajGarg  4 месяца назад +1

      Hi, The aggregation pipeline in compass given an option to export it to various language constructs like node.js, python or shell. The given code can be embedded in your choice of query execution engine ( programming language or shell).
      db.collection.aggregate(pipeline, options)
      an example from mongodb docs:
      db.orders.aggregate( [
      { $match: { status: "A" } },
      { $group: { _id: "$cust_id", total: { $sum: "$amount" } } },
      { $sort: { total: -1 } }
      ] )
      The following links can also be looked at for more details.
      www.mongodb.com/docs/manual/core/aggregation-pipeline/
      www.mongodb.com/docs/compass/current/create-agg-pipeline/
      www.mongodb.com/docs/manual/core/aggregation-pipeline/#run-an-aggregation-pipeline
      Hope this helps you. Please don't hesitate to get back.

  • @inspectatech
    @inspectatech 2 года назад +1

    How do I use the saved pipeline? Should i use the shell? where can i see more than "sample" results in compass? I haven't found a video that teaches this that explains what to do with the newly constructed pipeline.

    • @NeerajGarg
      @NeerajGarg  2 года назад

      You can export pipeline into the language of your choice (Python or NodeJS). You can watch my video from this link. This shows how to export pipeline from compass ( time 14:27 . ruclips.net/video/oJ0M9lJTzWU/видео.html&lc=UgxW7C8pLyGGjVmQ2md4AaABAg
      Let me know in case of any further query.

    • @inspectatech
      @inspectatech 2 года назад +1

      @@NeerajGarg thanks, for the hints in this video. I thought it would have been helpful to have the additional info on how to use the pipeline in this video. I kind of had to discover saving to a view and editing the view elsewhere.

    • @NeerajGarg
      @NeerajGarg  2 года назад

      thank you so much

  • @rajatjain2092
    @rajatjain2092 3 года назад +1

    Sir how can we use $lookup. I want to use that. like to update one field in one collection and it automatically updates in all collections that are linked with the previous one.

    • @NeerajGarg
      @NeerajGarg  2 года назад

      Thanks @rajat for your query. Based on my understanding, the lookup is used during select query operation in MongoDB. However, you can explore this link and let me know if this is of any help in your case docs.mongodb.com/manual/tutorial/update-documents-with-aggregation-pipeline/ . I think you might have to write a script to achieve this. I'm really sorry for the delayed response.

  • @qureshiowais6951
    @qureshiowais6951 2 года назад +1

    return state above 10m pop. can we use simple find ?

    • @NeerajGarg
      @NeerajGarg  2 года назад

      Yes, this should be a simple query and results can be fetched without any need of aggregation

  • @2911koti
    @2911koti 2 года назад

    Hi Neeraj...can you please explain how to join more than one collection and fetch data

    • @NeerajGarg
      @NeerajGarg  2 года назад

      Sure Koti, will create a video on this scenario and share as soon as possible. Thank you for sharing the requirement.
      Meanwhile, if there is any specific challenge you have been facing, please feel free to share with me. I'll reply as soon as possible (most likely in a day or so). I was engaged in some professional commitment, so could not revert earlier.

  • @vidhyasuresh1151
    @vidhyasuresh1151 3 года назад

    hello sir i have placement record details (around215) when i used match command it shows only 20 document even i have more than that. and also how to use nested queries sir please

    • @NeerajGarg
      @NeerajGarg  3 года назад

      @vidhya can you share more details like where are you running this query from? Is it from using mongo shell or compass? MongoDB, by default, returns 20 records. if you are using shell, you can use it.
      Where do you want to use nested queries. can you share exact requirement around nested query.