Query another cluster in the same account from a Realm Function

Is there a way to query another cluster in the same account from a Realm Function?

For example, if I have to clusterA and clusterB, is there a way to query a database.collection in clusterB from a trigger running on clusterA?

Currently the way to query a collection uses “context” but you don’t specify cluster name anywhere in the statement like this:



You can have multiple MongoDB services. The name “mongodb-atlas” is the default name given when you connect a cluster. If you go to “Linked Data Sources” in the UI you will see that you can connect multiple Atlas clusters and use them appropriately by specifying the name you see on that page.


Do I access the linked datasource like this?


That is correct. The default name / name for your existing cluster is just “mongodb-atlas”. So if you have a trigger on that cluster and in the function you want to insert to “mongodb-other” you can just reference context.services.get(“mongodb-other”).db(“mydb”)