Indexes

Indexes( [database] )
Indexes( )
ScopedIndexes( database )
Indexes( [database] )
Indexes( [database] )
indexes( [database] )
Indexes( [database] )

Description

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

When a child database is specified, an admin key must be used to call Indexes (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 ScopedIndexes function instead of Indexes.

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 indexes in the specified child database (or the current database if database is not specified).

Examples

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

    try
    {
        Value result = await client.Query(
            Paginate(Indexes())
        );
        Console.WriteLine(result);
    }
    catch (Exception e)
    {
        Console.WriteLine($"ERROR: {e.Message}");
    }
    ObjectV(data: Arr(RefV(id = "spells_by_element", collection = RefV(id = "indexes")), RefV(id = "spellbooks_by_owner", collection = RefV(id = "indexes")), RefV(id = "spells_by_spellbook", collection = RefV(id = "indexes")), RefV(id = "spells_by_element_and_name", collection = RefV(id = "indexes")), RefV(id = "elements_of_spells", collection = RefV(id = "indexes")), RefV(id = "letters", collection = RefV(id = "indexes")), RefV(id = "people_by_age_first", collection = RefV(id = "indexes")), RefV(id = "people_by_last_first", collection = RefV(id = "indexes")), RefV(id = "users_by_email", collection = RefV(id = "indexes")), RefV(id = "products_by_customer", collection = RefV(id = "indexes")), RefV(id = "products_by_store", collection = RefV(id = "indexes")), RefV(id = "inventory_by_product", collection = RefV(id = "indexes")), RefV(id = "products_by_prices_high_to_low", collection = RefV(id = "indexes")), RefV(id = "products_by_prices_low_to_high", collection = RefV(id = "indexes")), RefV(id = "all_customers", collection = RefV(id = "indexes")), RefV(id = "all_orders", collection = RefV(id = "indexes")), RefV(id = "all_products", collection = RefV(id = "indexes")), RefV(id = "all_stores", collection = RefV(id = "indexes"))))
    result, err := client.Query(
    	f.Paginate(f.Indexes()))
    
    if err != nil {
    	fmt.Fprintln(os.Stderr, err)
    } else {
    	fmt.Println(result)
    }
    map[data:[{spells_by_element 0xc00008f410 0xc00008f410 <nil>} {spellbooks_by_owner 0xc00008f500 0xc00008f500 <nil>} {spells_by_spellbook 0xc00008f5f0 0xc00008f5f0 <nil>} {spells_by_element_and_name 0xc00008f6e0 0xc00008f6e0 <nil>} {elements_of_spells 0xc00008f7d0 0xc00008f7d0 <nil>} {letters 0xc00008f8c0 0xc00008f8c0 <nil>} {people_by_age_first 0xc000136030 0xc000136030 <nil>} {people_by_last_first 0xc000136120 0xc000136120 <nil>} {users_by_email 0xc000136210 0xc000136210 <nil>} {products_by_customer 0xc000136300 0xc000136300 <nil>} {products_by_store 0xc0001363f0 0xc0001363f0 <nil>} {inventory_by_product 0xc0001364e0 0xc0001364e0 <nil>} {products_by_prices_high_to_low 0xc0001365d0 0xc0001365d0 <nil>} {products_by_prices_low_to_high 0xc0001366c0 0xc0001366c0 <nil>} {all_customers 0xc0001367b0 0xc0001367b0 <nil>} {all_orders 0xc0001368a0 0xc0001368a0 <nil>} {all_products 0xc000136990 0xc000136990 <nil>} {all_stores 0xc000136a80 0xc000136a80 <nil>}]]
    System.out.println(
        client.query(
            Paginate(Indexes())
        ).get());
    {data: [ref(id = "spells_by_element", collection = ref(id = "indexes")), ref(id = "spellbooks_by_owner", collection = ref(id = "indexes")), ref(id = "spells_by_spellbook", collection = ref(id = "indexes")), ref(id = "spells_by_element_and_name", collection = ref(id = "indexes")), ref(id = "elements_of_spells", collection = ref(id = "indexes")), ref(id = "letters", collection = ref(id = "indexes")), ref(id = "people_by_age_first", collection = ref(id = "indexes")), ref(id = "people_by_last_first", collection = ref(id = "indexes")), ref(id = "users_by_email", collection = ref(id = "indexes")), ref(id = "products_by_customer", collection = ref(id = "indexes")), ref(id = "products_by_store", collection = ref(id = "indexes")), ref(id = "inventory_by_product", collection = ref(id = "indexes")), ref(id = "products_by_prices_high_to_low", collection = ref(id = "indexes")), ref(id = "products_by_prices_low_to_high", collection = ref(id = "indexes")), ref(id = "all_customers", collection = ref(id = "indexes")), ref(id = "all_orders", collection = ref(id = "indexes")), ref(id = "all_products", collection = ref(id = "indexes")), ref(id = "all_stores", collection = ref(id = "indexes"))]}
    client.query(
      q.Paginate(q.Indexes())
    )
    .then((ret) => console.log(ret))
    .catch((err) => console.error('Error: %s', err))
    {
      data: [
        Index("spells_by_element"),
        Index("spellbooks_by_owner"),
        Index("spells_by_spellbook"),
        Index("spells_by_element_and_name"),
        Index("elements_of_spells"),
        Index("letters"),
        Index("people_by_age_first"),
        Index("people_by_last_first"),
        Index("users_by_email"),
        Index("products_by_customer"),
        Index("products_by_store"),
        Index("inventory_by_product"),
        Index("products_by_prices_high_to_low"),
        Index("products_by_prices_low_to_high"),
        Index("all_customers"),
        Index("all_orders"),
        Index("all_products"),
        Index("all_stores")
      ]
    }
    result = client.query(
      q.paginate(q.indexes())
    )
    print(result)
    {'data': [Ref(id=spells_by_element, collection=Ref(id=indexes)), Ref(id=spellbooks_by_owner, collection=Ref(id=indexes)), Ref(id=spells_by_spellbook, collection=Ref(id=indexes)), Ref(id=spells_by_element_and_name, collection=Ref(id=indexes)), Ref(id=elements_of_spells, collection=Ref(id=indexes)), Ref(id=letters, collection=Ref(id=indexes)), Ref(id=people_by_age_first, collection=Ref(id=indexes)), Ref(id=people_by_last_first, collection=Ref(id=indexes)), Ref(id=users_by_email, collection=Ref(id=indexes)), Ref(id=products_by_customer, collection=Ref(id=indexes)), Ref(id=products_by_store, collection=Ref(id=indexes)), Ref(id=inventory_by_product, collection=Ref(id=indexes)), Ref(id=products_by_prices_high_to_low, collection=Ref(id=indexes)), Ref(id=products_by_prices_low_to_high, collection=Ref(id=indexes)), Ref(id=all_customers, collection=Ref(id=indexes)), Ref(id=all_orders, collection=Ref(id=indexes)), Ref(id=all_products, collection=Ref(id=indexes)), Ref(id=all_stores, collection=Ref(id=indexes))]}
    try {
      println(Await.result(
        client.query(Paginate(Indexes())),
        5.seconds
      ))
    } catch {
      case unknown: Throwable => println("Error: " + unknown.getMessage())
    }
    {data: [ref(id = "spells_by_element", collection = ref(id = "indexes")), ref(id = "spellbooks_by_owner", collection = ref(id = "indexes")), ref(id = "spells_by_spellbook", collection = ref(id = "indexes")), ref(id = "spells_by_element_and_name", collection = ref(id = "indexes")), ref(id = "elements_of_spells", collection = ref(id = "indexes")), ref(id = "letters", collection = ref(id = "indexes")), ref(id = "people_by_age_first", collection = ref(id = "indexes")), ref(id = "people_by_last_first", collection = ref(id = "indexes")), ref(id = "users_by_email", collection = ref(id = "indexes")), ref(id = "products_by_customer", collection = ref(id = "indexes")), ref(id = "products_by_store", collection = ref(id = "indexes")), ref(id = "inventory_by_product", collection = ref(id = "indexes")), ref(id = "products_by_prices_high_to_low", collection = ref(id = "indexes")), ref(id = "products_by_prices_low_to_high", collection = ref(id = "indexes")), ref(id = "all_customers", collection = ref(id = "indexes")), ref(id = "all_orders", collection = ref(id = "indexes")), ref(id = "all_products", collection = ref(id = "indexes")), ref(id = "all_stores", collection = ref(id = "indexes"))]}
  2. The following query lists the References for any indexes (up to the pagination limit) in a child database named "child_db":

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

try
{
    Value result = await client.Query(
        Paginate(Indexes())
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
ObjectV(data: Arr())
result, err := client.Query(
	f.Paginate(f.Indexes()))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
map[data:[]]
System.out.println(
    client.query(
        Paginate(Indexes())
    ).get());
{data: []}
client.query(
  q.Paginate(q.Indexes())
)
.then((ret) => console.log(ret))
.catch((err) => console.error('Error: %s', err))
{ data: [] }
result = client.query(
  q.paginate(q.indexes())
)
print(result)
{'data': []}
try {
  println(Await.result(
    client.query(
      Paginate(Indexes())
    ),
    5.seconds
  ))
} catch {
  case unknown: Throwable => println("Error: " + unknown.getMessage())
}
{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!