List all child databases

Reading or writing database documents requires an admin key.

Problem

You need a list of all child databases within the current database.

Solution

Use the Databases function combined with the Paginate function:

try
{
    Value result = await client.Query(
        Paginate(Databases())
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
ObjectV(data: Arr(RefV(id = "prydain", collection = RefV(id = "databases")), RefV(id = "child_db", collection = RefV(id = "databases")), RefV(id = "annuvin", collection = RefV(id = "databases"))))
result, err := adminClient.Query(
	f.Paginate(f.Databases()))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
map[data:[{prydain 0xc0000924b0 0xc0000924b0 <nil>} {child_db 0xc0000925a0 0xc0000925a0 <nil>} {annuvin 0xc000092690 0xc000092690 <nil>}]]
System.out.println(
        adminClient.query(
            Paginate(Databases())
        ).get());
{data: [ref(id = "prydain", collection = ref(id = "databases")), ref(id = "child_db", collection = ref(id = "databases")), ref(id = "annuvin", collection = ref(id = "databases"))]}
adminClient.query(
  q.Paginate(q.Databases())
)
.then((ret) => console.log(ret))
.catch((err) => console.error('Error: %s', err))
{
  data: [ Database("prydain"), Database("child_db"), Database("annuvin") ]
}
result = adminClient.query(
  q.paginate(q.databases())
)
print(result)
{'data': [Ref(id=prydain, collection=Ref(id=databases)), Ref(id=child_db, collection=Ref(id=databases)), Ref(id=annuvin, collection=Ref(id=databases))]}
try {
  println(Await.result(
    client.query(
        Paginate(Databases())
    ),
    5.seconds
  ))
} catch {
  case unknown: Throwable => println("Error: " + unknown.getMessage())
}
{data: [ref(id = "prydain", collection = ref(id = "databases")), ref(id = "child_db", collection = ref(id = "databases")), ref(id = "annuvin", collection = ref(id = "databases"))]}
Paginate(Databases())
{
  data: [ Database("prydain"), Database("child_db"), Database("annuvin") ]
}

Discussion

The Paginate function defaults to returning up to 64 databases per page. If your database contains more than 64 databases, you can use the size parameter to retrieve up to 100,000 databases at once.

More information

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve!
Visit Fauna's Discourse forums or email docs@fauna.com

Thank you for your feedback!