List all functions

Reading or writing database documents requires an admin key.

Problem

You need to retrieve a list of all functions within the current database.

Solution

Use the Functions function combined with the Paginate function:

try
{
    Value result = await client.Query(
        Paginate(Functions())
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
ObjectV(data: Arr(RefV(id = "increment", collection = RefV(id = "functions")), RefV(id = "double", collection = RefV(id = "functions")), RefV(id = "submit_order", collection = RefV(id = "functions")), RefV(id = "create_post", collection = RefV(id = "functions"))))
result, err := client.Query(
	f.Paginate(f.Functions()))

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

Discussion

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

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!