Indexes

This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics.

Indexes( [database] )
Indexes( )
ScopedIndexes( 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

Parameter Type Definition and Requirements

database

Reference

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.

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_price_high_to_low", collection = RefV(id = "indexes")), RefV(id = "products_by_price_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_price_high_to_low 0xc0001365d0 0xc0001365d0 <nil>} {products_by_price_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>}]]
    client.query(
      q.Paginate(q.Indexes())
    )
    .then((ret) => console.log(ret))
    .catch((err) => console.error(
      'Error: [%s] %s: %s',
      err.name,
      err.message,
      err.errors()[0].description,
    ))
    {
      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_price_high_to_low"),
        Index("products_by_price_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_price_high_to_low, collection=Ref(id=indexes)), Ref(id=products_by_price_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))]}
    Paginate(Indexes())
    {
      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_price_high_to_low"),
        Index("products_by_price_low_to_high"),
        Index("all_customers"),
        Index("all_orders"),
        Index("all_products"),
        Index("all_stores")
      ]
    }
    Query metrics:
    •    bytesIn:    29

    •   bytesOut: 1,386

    • computeOps:     1

    •    readOps:     8

    •   writeOps:     0

    •  readBytes:   964

    • writeBytes:     0

    •  queryTime:  46ms

    •    retries:     0

  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:[]]
    client.query(
      q.Paginate(q.Indexes(q.Database('child_db')))
    )
    .then((ret) => console.log(ret))
    .catch((err) => console.error(
      'Error: [%s] %s: %s',
      err.name,
      err.message,
      err.errors()[0].description,
    ))
    { data: [] }
    result = client.query(
      q.paginate(q.indexes(q.database("child_db")))
    )
    print(result)
    {'data': []}
    Paginate(Indexes(Database('child_db')))
    { data: [] }
    Query metrics:
    •    bytesIn:   48

    •   bytesOut:   24

    • computeOps:    1

    •    readOps:    8

    •   writeOps:    0

    •  readBytes:  363

    • writeBytes:    0

    •  queryTime: 17ms

    •    retries:    0

  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:[]]
client.query(
  q.Paginate(q.Indexes())
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
{ data: [] }
result = client.query(
  q.paginate(q.indexes())
)
print(result)
{'data': []}
Paginate(Indexes())
{ data: [] }
Query metrics:
  •    bytesIn:    29

  •   bytesOut:    24

  • computeOps:     1

  •    readOps:     8

  •   writeOps:     0

  •  readBytes:   208

  • writeBytes:     0

  •  queryTime: 583ms

  •    retries:     0

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!