FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date.

For more details, review the migration guide. Contact support@fauna.com with any questions.

Get a database document

Reading or writing database documents requires an admin key.

Problem

You need to retrieve the document that describes a child database.

Solution

Use the Get function:

adminClient.query(
  q.Get(q.Database('annuvin'))
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
{
  ref: Database("annuvin"),
  ts: 1622573508720000,
  name: 'annuvin',
  global_id: 'yoiji573cydyy'
}
result = adminClient.query(
  q.get(q.database("annuvin"))
)
print(result)
{'ref': Ref(id=annuvin, collection=Ref(id=databases)), 'ts': 1622573511610000, 'name': 'annuvin', 'global_id': 'yoijihdqgydyy'}
result, err := adminClient.Query(
	f.Get(f.Database("annuvin")))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
map[global_id:yoiji3uwcybyy name:annuvin ref:{annuvin 0xc0001804b0 0xc0001804b0 <nil>} ts:1622573470750000]
try
{
    Value result = await client.Query(
        Get(Database("annuvin"))
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
ObjectV(ref: RefV(id = "annuvin", collection = RefV(id = "databases")),ts: LongV(1622573448030000),name: StringV(annuvin),global_id: StringV(yoijia8e1ybyy))
Get(Database('annuvin'))
{
  ref: Database("annuvin"),
  ts: 1624310575420000,
  name: 'annuvin',
  global_id: 'yoat8nnggybyy'
}
Query metrics:
  •    bytesIn:  30

  •   bytesOut: 154

  • computeOps:   1

  •    readOps:   1

  •   writeOps:   0

  •  readBytes: 153

  • writeBytes:   0

  •  queryTime: 7ms

  •    retries:   0

Discussion

It is not possible to access the parent database, the current database, or any of the current database’s peers (that may exist) using Get. You can only retrieve the documents that describe child databases.

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!