How I can achieve device sync into an specific database?

Hello community, I’m pretty new to Realm and I would like to know if this could be possible using Realm and Atlas device Sync.

I’m making an app that has multiple tenants. The thing is, each set of data for each tenant, must be preferably inside its own database in Realm so that is 1 tenant = 1 database.
But the thing is, I can’t find that option anywhere in the admin panel or where I can specify to which database I’m going to sync the data and create it. That means when I login with Tenant A, that user only sees the data from Tenant A in Database from Tenant A.

I’m pretty blocked right now, so any guide is really appreciated.

Thanks in advance.

I’d recommend putting all your data in a single database collection, but including a field on each document indicating which tenant it belongs to.

Then, you can open a flexible sync subscription on the device that filters on just the data relevant to the logged-in tenant. You can also use permissions and custom user data to ensure that a user is not allowed to read data that does not belong to them.

As an alternative, if you know all the tenants up front, you could create separate databases, App Services Apps, and realm databases (each syncing to a different App Service) for each tenant. I don’t think the overhead for this is worth it though, and I wouldn’t recommend it

But is the entire database going to sync to every device that is connected with that appservice ID? Or that can be managed with permissions?

I understand that the filter you are mentioning is in the frontend when I do the queries to the local Realm.

You can use either the subscription in your sdk code or server-side permissions (or both!) to control and limit the data that syncs down to the device

But isn’t the data from the cluster binded into the appservice? Is it possible to change the appservice on the fly? Like when I logout and then login in the app with another tenant, use a different appservice ID?