I don’t think MongoDB can join two databases where one is on-prem, but I believe you can join multiple MongoDB Atlas based databases in a single query using Atlas Data Federation. Using Data Federation you can also join Atlas Data Lake and data in AWS S3 buckets.
Nothing stops you from implementing your own federation.
You just connect your application to the 2 servers, reading data from both and storing the result where ever you wish.
You can even do that by simply doing 2 mongodump, one from each servers. The mongorestore to 2 different databases to the target mongod, then use aggregation with $merge in the order you want.
Salut Steeve! Yes, we have the middleware in our project and I’m able to call the api routes to get data from the desired collections. Actually I need to compare metadata in related collections and update data in the local collection by the user call by the running a script (Node + js). This script (Node + js) does not work properly and we do not use refs in our mongoose schema . I’d like ro rewrite it with using aggregation func. Could you, pls, write for me the short example of code how to create/merge those collections to temporary/ virtual DB, then put make to aggregation func.?