Indexes

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

Parameters

Argument Type Definition and Requirements

database

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

The following query gets the references to all indexes in the current database:

client.Query(Paginate(Indexes()));
[{ "@ref": "indexes/spells_by_element" }]
curl https://db.fauna.com/ \
    -u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
    -d '{ "paginate": { "indexes": null } }'
HTTP/1.1 200 OK
{ "resource": [{ "@ref": "indexes/spells_by_element" }] }
result, _ := client.Query(f.Paginate(f.Indexes()))

fmt.Println(result)
[{spells_by_element 0xc4202d0fa0 <nil>}]
System.out.println(client.query(Paginate(Indexes())).get());
[ref(id = "spells_by_element", collection = ref(id = "indexes"))]
client.query(q.Paginate(q.Indexes()))
.then((ret) => console.log(ret))
[Ref(id=spells_by_element, collection=Ref(id=indexes))]
client.query(q.paginate(q.indexes()))
[{ "@ref": "indexes/spells_by_element" }]
client.query(Paginate(Indexes()))
[{ "@ref": "indexes/spells_by_element" }]

The following query demonstrates what happens when no indexes exist:

Value result = await client.Query(
  Paginate(Indexes())
);

IResult<Value> data = result.To<Value>();
data.Match(
  Success: value => Console.WriteLine($"{value}"),
  Failure: error => Console.WriteLine($"Query failed:\n{error}")
);
ObjectV(data: Arr())
Not available in this language yet.
result, err := client.Query(
  f.Paginate(f.Indexes()))

if (err != nil) {
  fmt.Println(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))
{ data: [] }
print(client.query(
  q.paginate(q.indexes())
))
{'data': []}
println(Await.result(
  client.query(
    Paginate(Indexes())
  ),
  5.seconds
))
{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!