Access to a child database from within a parent's UDF

After looking through the tutorial at Multi-tenancy | Fauna Documentation I noticed on Step 4 that to work with a child database you have to create a new shell and supply the secret for the child database. This gives the shell the context for future queries and commands.

I was wondering, is it possible to have this ‘new context’ switch from within a parent UDF?

I’d love to be able to call a parent function supplying it with a child database secret and have It query on my behalf.

The secret required to access a database is supplied via a HTTP header. A UDF cannot make HTTP queries, so it cannot change contexts mid-query.

It is possible to use a “scoped” key to access child databases, see Keys | Fauna Documentation

Also, a key/token with the “admin” role can perform read-only queries in child databases, but a database-specific or scoped key is required to perform writes in child databases.

1 Like