I have a collection to store
users where each document will have an array of blocked users. The array will be capped at 1000. If the user exceeds this number, then the outlier pattern will be used and the overflow of blocked users will be stored in a separate collection,
I have an aggregation pipeline that will return a list of suggested users. One of the filters is to check this blocked users array.
There will be a flag in the
user collection to indicate whether or not there additional blocked users for a particular document.
The majority of documents will not exceed 1000. So it only makes sense to call the $lookup on those documents that do exceed the limit, i.e. where the flag is true.
How can this be done, calling $lookup conditionally?