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

After looking through the tutorial at Databases and multi-tenancy - Fauna Docs 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

How to do a read only query of a child database? I’ve looked through the docs but cannot find this info.

Thank you

The latest link for scoped keys is here: Keys - Fauna Docs

Reading data in a child database with a key for the parent is not possible with FQL v10. You will need to configure your client to query the child db with the appropriate key.

1 Like