Keys

Keys( [database] )
Keys( )
ScopedKeys( database )
Keys( [database] )
Keys( [database] )
keys( [database] )
Keys( [database] )
Keys( [database] )

Description

The Keys function, when executed with Paginate, returns an array of References for authentication keys associated with the specified child database. If a child database is not specified, the returned key references all belong to the current database.

When a child database is specified, an admin key must be used to call Keys (server or client keys, or ABAC tokens, cannot be used to access a child database).

Also, Go does not support optional function parameters, nor function overloading. To specify a child database using the Go driver, call the ScopedKeys function instead of Keys.

Parameters

Argument Type Definition and Requirements

database

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

A Reference to a child database.

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

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

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

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

Returns

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

Examples

  1. The following query lists the References for any keys (up to the pagination limit) in the current database:

    try
    {
        Value result = await client.Query(
            Paginate(Keys())
        );
        Console.WriteLine(result);
    }
    catch (Exception e)
    {
        Console.WriteLine($"ERROR: {e.Message}");
    }
    ObjectV(data: Arr(RefV(id = "1", collection = RefV(id = "keys")), RefV(id = "2", collection = RefV(id = "keys"))))
    result, err := client.Query(
    	f.Paginate(f.Keys()))
    
    if err != nil {
    	fmt.Fprintln(os.Stderr, err)
    } else {
    	fmt.Println(result)
    }
    map[data:[{1 0xc0001480c0 0xc0001480c0 <nil>} {2 0xc0001481b0 0xc0001481b0 <nil>}]]
    System.out.println(
        client.query(
            Paginate(Keys())
        ).get());
    {data: [ref(id = "1", collection = ref(id = "keys")), ref(id = "2", collection = ref(id = "keys"))]}
    client.query(
      q.Paginate(q.Keys())
    )
    .then((ret) => console.log(ret))
    .catch((err) => console.error('Error: %s', err))
    { data: [ Ref(Keys(), "1"), Ref(Keys(), "2") ] }
    result = client.query(
      q.paginate(q.keys())
    )
    print(result)
    {'data': [Ref(id=1, collection=Ref(id=keys)), Ref(id=2, collection=Ref(id=keys))]}
    try {
      println(Await.result(
      client.query(
        Paginate(Keys())
      ),
      5.seconds
    ))} catch {
      case unknown: Throwable => println("Error: " + unknown.getMessage())
    }
    {data: [ref(id = "1", collection = ref(id = "keys")), ref(id = "2", collection = ref(id = "keys"))]}
    Paginate(Keys())
    { data: [ Ref(Keys(), "1"), Ref(Keys(), "2") ] }
  2. The following query lists the References for any keys (up to the pagination limit) in a child database named "child_db":

    try
    {
        Value result = await client.Query(
            Paginate(Keys(Database("child_db")))
        );
        Console.WriteLine(result);
    }
    catch (Exception e)
    {
        Console.WriteLine($"ERROR: {e.Message}");
    }
    ObjectV(data: Arr())
    result, err := client.Query(
    	f.Paginate(f.ScopedKeys(f.Database("child_db"))))
    
    if err != nil {
    	fmt.Fprintln(os.Stderr, err)
    } else {
    	fmt.Println(result)
    }
    map[data:[]]
    System.out.println(
        client.query(
            Paginate(Keys(Database("child_db")))
        ).get());
    {data: []}
    client.query(
      q.Paginate(q.Keys(q.Database('child_db')))
    )
    .then((ret) => console.log(ret))
    .catch((err) => console.error('Error: %s', err))
    { data: [] }
    result = client.query(
      q.paginate(q.keys(q.database("child_db")))
    )
    print(result)
    {'data': []}
    try {
      println(Await.result(
      client.query(
        Paginate(Keys(Database("child_db")))
      ),
      5.seconds
    ))} catch {
      case unknown: Throwable => println("Error: " + unknown.getMessage())
    }
    {data: []}
    Paginate(Keys(Database('child_db')))
    { data: [] }

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!