Databases

Databases( [database] )
Databases( [database] )
Databases( [database] )
Databases( [database] )
databases( [database] )
Databases( [database] )

Description

The Databases function, when executed with Paginate, returns an array of References for child databases in the specified child database. If a child database is not specified, the returned child database references all belong to the current database.

The Databases function only reports child databases, so finding a database using this function requires you to use an admin key for the current database (a server or client key cannot be used to access any child database).

Parameters

Argument Type Definition and Requirements

database

Optional - A reference to a child database. If not specified, the current database is used.

Returns

A Set reference for the available databases in the specified child database (or the current database if database is not specified).

Examples

The query below retrieves the references to sub-databases within the current database:

client.Query(Paginate(Databases()));
[{ "@ref": "databases/prydain" }]
curl https://db.fauna.com/ \
    -u fnAChGwBacACAEZtRZFDXpyjIvq-sln34m-va4Km: \
    -d '{ "paginate": { "databases": null } }'
HTTP/1.1 200 OK
{ "resource": [{ "@ref": "databases/prydain" }] }
result, _ := client.Query(f.Paginate(f.Databases()))

fmt.Println(result)
[{prydain 0xc420316a60 <nil>}]
System.out.println(client.query(Paginate(Databases())).get());
[ref(id = "prydain", collection = ref(id = "databases"))]
client.query(q.Paginate(q.Databases()))
.then((ret) => console.log(ret))
[Ref(id=prydain, collection=Ref(id=databases))]
client.query(q.paginate(q.databases()))
[{ "@ref": "databases/prydain" }]
client.query(Paginate(Databases()))
[{ "@ref": "databases/prydain" }]

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!