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 .
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.
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.
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.
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.
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.
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.
@@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.
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.
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.
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.
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
@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.
Very clean explaination sir.
I like your videos..!
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 .
definitely @@NeerajGarg
Desde México, muchas gracias por el video me ayudo mucho, saludos.
Muchas gracias por sus comentarios. Esto realmente me ha motivado a compartir mis conocimientos con la comunidad.
Great
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.
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.
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.
Hi Sreevathsava, can you please share couple of sample documents along with expected output. I'll share query with you
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.
thanks
You're welcome!
after creating pipeline, how do you run it?
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.
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.
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.
@@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.
thank you so much
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.
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.
return state above 10m pop. can we use simple find ?
Yes, this should be a simple query and results can be fetched without any need of aggregation
Hi Neeraj...can you please explain how to join more than one collection and fetch data
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.
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
@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.