Merge operation when using multiple collections

I have started working on mongodb a month ago and going well. I fell in love with this actually.

going to the topic:

I need to create a new collection by joining 4 collections. Successfully did this, but I don’t want to execute this query on entire table every time. So I thought of using Merge. So the question here is , data in these 4 collections can change at any time. How can I bring data that was changed in the collections that are joined to main collection when no data changed in the main collection?

For ex: Let’s say I am joining collection A (this is the main one with 15 million docs) with collections B,C, and D. If there is any changes in A that can be pulled and joined with other collections… no issues here.

But take case where collection A doesn’t have any changes in past 1 hour, but collection C has some changes. Now how can I bring changes in the collection C (it is only used in Lookup) ?

Is there a better way to achieve this ?

Thanks in advance.
Chuck

If I understand you right, I do not think there is another way to do it without scanning all collections… UNLESS, there is a field indicates that document has changed since last merge… a flag; change = true or timestamp; changed_at …