I am working on a multi-tenancy architecture using FaunaDB where each team of users has a dedicated child database.
I am trying to create a collection (Users
) inside the child database, where data about the team and its users is saved.
I am using Fauna's Javascript client. The following code creates a collection at the top level database, while I am trying to add it into the child database.
var user = await faunaClient.query(
q.Create(
q.Collection('users'),
{ data: ctx.currentUser }
)
)
How can I adapt it to specify the collection inside the child database?
Do I need to pass a reference to the child database somewhere? Or should I instantiate a new Fauna client, with a key from the child database?
If you have the admin key of the parent database you can access the child from a new client based on that secret. Format the secret like so admin_secret:child_db_name:role